diff --git a/mytv/alpine/nginx.conf b/mytv/alpine/nginx.conf index a48b643..5d4b6df 100644 --- a/mytv/alpine/nginx.conf +++ b/mytv/alpine/nginx.conf @@ -407,6 +407,77 @@ http { } } + # 反代设置:第六个网站 + server { + listen 20005; + listen [::]:20005; + server_name cdn.1678520.xyz; + + # 屏蔽 Cloudflare 响应头 + proxy_hide_header Server; + #proxy_hide_header CF-Cache-Status; + #proxy_hide_header CF-Ray; + proxy_hide_header Alt-Svc; + proxy_hide_header Expect-CT; + proxy_hide_header report-to; + proxy_hide_header Nel; + proxy_hide_header server-timing; + + # 自定义响应头:缓存命中状态和剩余缓存时间 + add_header X-Cache-Status $upstream_cache_status; + add_header X-Cache-TTL $upstream_http_x_cache_ttl; + add_header X-Cache-Key $scheme$host$request_uri; + + # 代理头设置 + 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.tvfix.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 my_cache; # 使用指定的缓存区域 + proxy_cache_lock on; # 启用缓存锁 + proxy_cache_key "$scheme$host$request_uri"; #缓存 Key + proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒 + proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头 + expires 5s; # 设置浏览器端缓存 5 秒 + + # 默认 location 配置 + location / { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + } + + proxy_pass https://live.tvfix.org; + + } + + # 针对 .ts 和 .aac 文件的特殊缓存设置 + location ~* \.(ts|webvtt|key)$ { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + } + + proxy_pass https://live.tvfix.org; # 替换为您的源站地址 + proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 + expires 60s; # 设置浏览器端缓存 60 秒 + + } + } + # 反代设置:第七个网站 server { listen 20006;