mirror of
https://github.com/rad168/iptv.git
synced 2025-12-17 15:25:00 +08:00
547 lines
20 KiB
Nginx Configuration File
547 lines
20 KiB
Nginx Configuration File
user www-data;
|
||
worker_processes auto;
|
||
pid /run/nginx.pid;
|
||
include /etc/nginx/modules-enabled/*.conf;
|
||
|
||
events {
|
||
worker_connections 1024; # 提高连接数上限
|
||
multi_accept on; # 允许多连接同时接受
|
||
}
|
||
|
||
http {
|
||
|
||
##
|
||
# 基本设置
|
||
##
|
||
sendfile on;
|
||
tcp_nopush on;
|
||
tcp_nodelay on;
|
||
keepalive_timeout 65;
|
||
types_hash_max_size 2048;
|
||
|
||
include /etc/nginx/mime.types;
|
||
default_type application/octet-stream;
|
||
|
||
##
|
||
# SSL 设置
|
||
##
|
||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
|
||
ssl_prefer_server_ciphers on;
|
||
|
||
##
|
||
# 日志设置
|
||
##
|
||
set_real_ip_from 0.0.0.0/0; # 允许所有代理传递真实 IP
|
||
real_ip_header X-Forwarded-For;
|
||
real_ip_recursive on;
|
||
log_format custom '$remote_addr - $remote_user [$time_local] "$request" '
|
||
'$status $body_bytes_sent "$http_referer" '
|
||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||
access_log /var/log/nginx/access.log;
|
||
error_log /var/log/nginx/error.log;
|
||
|
||
##
|
||
# Gzip 压缩设置
|
||
##
|
||
gzip on;
|
||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript video/mp2t;
|
||
|
||
##
|
||
# 缓存路径配置
|
||
##
|
||
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=cache_zone:10m max_size=500m inactive=24h use_temp_path=off;
|
||
|
||
##
|
||
# 虚拟主机配置
|
||
##
|
||
include /etc/nginx/conf.d/*.conf;
|
||
#include /etc/nginx/sites-enabled/*;
|
||
|
||
server {
|
||
listen 20000;
|
||
listen [::]:20000;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host cdn.163.dedyn.io; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://cdn.163.dedyn.io; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://cdn.163.dedyn.io; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20001;
|
||
listen [::]:20001;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host live.cdn.com.mp; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://live.cdn.com.mp; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://live.cdn.com.mp; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20002;
|
||
listen [::]:20002;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host cdn6.zone.id; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://cdn6.zone.id; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://cdn6.zone.id; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
|
||
# 针对包含 smt2.1.5.php 的 URL,设置缓存时间为 60 秒
|
||
location ~ smt2\.1\.5\.php {
|
||
proxy_cache_valid 200 206 60s; # 缓存 60 秒
|
||
expires 60s; # 设置浏览器缓存 60 秒
|
||
proxy_pass https://cdn6.zone.id;
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20003;
|
||
listen [::]:20003;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host cdn6.0o0.myfw.us; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://cdn6.0o0.myfw.us; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://cdn6.0o0.myfw.us; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20004;
|
||
listen [::]:20004;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host v2h.1789.dpdns.org; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass http://v2h.1789.dpdns.org; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass http://v2h.1789.dpdns.org; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20006;
|
||
listen [::]:20006;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host cdn5.zone.id; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://cdn5.zone.id; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://cdn5.zone.id; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20007;
|
||
listen [::]:20007;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host tv.cdn.com.mp; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://tv.cdn.com.mp; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://tv.cdn.com.mp; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20008;
|
||
listen [::]:20008;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host aktv_stream.m16tv.cfd; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass http://aktv_stream.m16tv.cfd; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 m3u8 文件内容修改
|
||
location ~ \.m3u8$ {
|
||
proxy_pass http://aktv_stream.m16tv.cfd;
|
||
|
||
# 替换为相对路径
|
||
sub_filter 'http://aktv_stream.m16tv.cfd/AKTV/stream/' '/AKTV/stream/';
|
||
sub_filter_once off;
|
||
sub_filter_types application/vnd.apple.mpegurl text/plain;
|
||
|
||
# 解压 gzip 压缩内容(如源站启用了压缩)
|
||
gzip off;
|
||
proxy_set_header Accept-Encoding "";
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass http://aktv_stream.m16tv.cfd; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
|
||
# 针对 m3u 文件内容修改
|
||
location ~ \.m3u$ {
|
||
proxy_pass http://aktv_stream.m16tv.cfd;
|
||
|
||
# 替换为相对路径
|
||
sub_filter 'http://aktv_stream.m16tv.cfd' 'http://$host:20008';
|
||
sub_filter_once off;
|
||
sub_filter_types application/vnd.apple.mpegurl text/plain;
|
||
|
||
# 解压 gzip 压缩内容(如源站启用了压缩)
|
||
gzip off;
|
||
proxy_set_header Accept-Encoding "";
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20009;
|
||
listen [::]:20009;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host cdn8.zone.id; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://cdn8.zone.id; # 替换为您的源站地址
|
||
}
|
||
|
||
# 针对 .ts 和 .aac 文件的特殊缓存设置
|
||
location ~* \.(ts|aac)$ {
|
||
proxy_pass https://cdn8.zone.id; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 20010;
|
||
listen [::]:20010;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置(测试区网站未设置ts文件缓存)
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location / {
|
||
proxy_pass https://mytv.cdn.com.mp; # 替换为您的源站地址
|
||
proxy_set_header Host mytv.cdn.com.mp; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
}
|
||
|
||
# /hw/ 子目录
|
||
location /hw/ {
|
||
proxy_pass https://hw.1678520.xyz/;
|
||
proxy_set_header Host hw.1678520.xyz; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
}
|
||
}
|
||
|
||
server {
|
||
listen 30000;
|
||
listen [::]:30000;
|
||
server_name cdn.1678520.xyz; # 替换为您的域名
|
||
|
||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||
add_header X-Cache-Status $upstream_cache_status;
|
||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||
|
||
# 代理头设置
|
||
proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||
proxy_set_header Host raw.githubusercontent.com;
|
||
|
||
# SSL 配置
|
||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||
proxy_ssl_server_name on;
|
||
|
||
# 默认缓存配置
|
||
proxy_cache cache_zone; # 使用指定的缓存区域
|
||
proxy_cache_lock on; # 启用缓存锁
|
||
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
|
||
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
|
||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||
expires 5s; # 设置浏览器端缓存 5 秒
|
||
|
||
# 默认 location 配置
|
||
location /mytv.m3u {
|
||
proxy_pass https://raw.githubusercontent.com/rad168/iptv/refs/heads/main/mytv.m3u; # 替换为您的源站地址
|
||
sub_filter '服务器ip' '$host';
|
||
sub_filter_once off; # 替换所有匹配项
|
||
sub_filter_types *; # 对所有 MIME 类型进行替换
|
||
|
||
# 解压 gzip 压缩内容(如源站启用了压缩)
|
||
gzip off;
|
||
proxy_set_header Accept-Encoding "";
|
||
|
||
}
|
||
}
|
||
|
||
}
|