diff --git a/nginx.conf b/nginx.conf index 0a4c125..55440ce 100644 --- a/nginx.conf +++ b/nginx.conf @@ -57,6 +57,31 @@ http { include /etc/nginx/conf.d/*.conf; #include /etc/nginx/sites-enabled/*; + # 定义 token 来源优先级:URL > Cookie + map $arg_token $token_to_check { + default $cookie_token; + ~.+ $arg_token; + } + + # 定义允许的 token 列表(把第69行的"mytv123"修改为你自己的token) + map $token_to_check $auth_ok { + default 0; + "mytv123" 1; + #"abc" 1; # 可选:支持多个 token + } + + # 去除 token 参数,保留其他参数 + map $args $args_clean { + default $args; + ~^(.*)(^|&)token=[^&]*&?(.*)$ $1$3; + } + + # 根据是否有参数构造跳转地址 + map $args_clean $redirect_uri { + "" $uri; # 没参数:只保留路径 + default $uri?$args_clean; # 有参数:加 ? + } + server { listen 20000; listen [::]:20000; @@ -66,10 +91,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 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.163189.xyz; # 确保请求的 Host 匹配 Cloudflare 配置 + proxy_set_header Host cdn.16899.ggff.net; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -87,12 +122,30 @@ http { # 默认 location 配置 location / { - proxy_pass https://cdn.163189.xyz; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn.16899.ggff.net; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://cdn.163189.xyz; # 替换为您的源站地址 + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn.16899.ggff.net; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -107,10 +160,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 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 配置 + proxy_set_header Host live.101.qzz.io; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -128,12 +191,30 @@ http { # 默认 location 配置 location / { - proxy_pass https://live.cdn.com.mp; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://live.101.qzz.io; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://live.cdn.com.mp; # 替换为您的源站地址 + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://live.101.qzz.io; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -148,10 +229,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理 - proxy_set_header Host cdn12.jdshipin.com; # 确保请求的 Host 匹配 Cloudflare 配置 + proxy_set_header Host smt.1789.dpdns.org; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -169,21 +260,32 @@ http { # 默认 location 配置 location / { - proxy_pass https://cdn12.jdshipin.com; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } - # 针对 .ts 和 .aac 文件的特殊缓存设置 - location ~* \.(ts|aac)$ { - proxy_pass https://cdn12.jdshipin.com; # 替换为您的源站地址 - proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 - expires 60s; # 设置浏览器端缓存 60 秒 - } + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://smt.1789.dpdns.org; # 替换为您的源站地址 + } # 针对包含 smt2.1.5.php 的 URL,设置缓存时间为 60 秒 location ~ smt2\.1\.5\.php { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + proxy_cache_valid 200 206 60s; # 缓存 60 秒 expires 60s; # 设置浏览器缓存 60 秒 - proxy_pass https://cdn12.jdshipin.com; + proxy_pass https://smt.1789.dpdns.org; } } @@ -196,10 +298,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 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 配置 + proxy_set_header Host cdn6.16899.ggff.net; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -217,12 +329,30 @@ http { # 默认 location 配置 location / { - proxy_pass https://cdn6.0o0.myfw.us; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn6.16899.ggff.net; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://cdn6.0o0.myfw.us; # 替换为您的源站地址 + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn6.16899.ggff.net; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -237,10 +367,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理 - proxy_set_header Host v2hcdn.jdshipin.com; # 确保请求的 Host 匹配 Cloudflare 配置 + proxy_set_header Host v2h.1789.dpdns.org; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -258,12 +398,30 @@ http { # 默认 location 配置 location / { - proxy_pass https://v2hcdn.jdshipin.com; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass http://v2h.1789.dpdns.org; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://v2hcdn.jdshipin.com; # 替换为您的源站地址 + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass http://v2h.1789.dpdns.org; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -278,14 +436,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; - # 固定请求头 - proxy_set_header User-Agent "TiviMate/5.1.0"; - proxy_set_header Referer "https://edge3.hkdvb.com/"; - proxy_set_header Host edge3.hkdvb.com; # 确保请求的 Host 匹配 Cloudflare 配置 + # 屏蔽 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; # 代理头设置 - #proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP + 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 协议 @@ -303,12 +467,30 @@ http { # 默认 location 配置 location / { - proxy_pass https://edge3.hkdvb.com; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://live.tvfix.org; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 - location ~* \.(ts|aac)$ { - proxy_pass https://edge3.hkdvb.com; # 替换为您的源站地址 + 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=/"; + return 302 $redirect_uri; + } + + proxy_pass https://live.tvfix.org; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -323,10 +505,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 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.cdn5.rr.nu; # 确保请求的 Host 匹配 Cloudflare 配置 + proxy_set_header Host cdn5.zone.id; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -344,12 +536,30 @@ http { # 默认 location 配置 location / { - proxy_pass https://tv.cdn5.rr.nu; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn5.zone.id; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://tv.cdn5.rr.nu; # 替换为您的源站地址 + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn5.zone.id; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -364,10 +574,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 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 配置 + proxy_set_header Host cdn2.16899.ggff.net; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -385,12 +605,31 @@ http { # 默认 location 配置 location / { - proxy_pass https://tv.cdn.com.mp; # 替换为您的源站地址 - } + + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn2.16899.ggff.net; # 替换为您的源站地址 + } # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://tv.cdn.com.mp; # 替换为您的源站地址 + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn2.16899.ggff.net; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } @@ -405,10 +644,20 @@ http { add_header X-Cache-Status $upstream_cache_status; add_header X-Cache-TTL $upstream_http_x_cache_ttl; + # 屏蔽 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; + # 代理头设置 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.top; # 确保请求的 Host 匹配 Cloudflare 配置 + proxy_set_header Host aktv_stream.m16tv.cfd; # 确保请求的 Host 匹配 Cloudflare 配置 # SSL 配置 proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议 @@ -426,15 +675,33 @@ http { # 默认 location 配置 location / { - proxy_pass https://aktv.top; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass http://aktv_stream.m16tv.cfd; # 替换为您的源站地址 + } # 针对 m3u8 文件内容修改 location ~ \.m3u8$ { - proxy_pass https://aktv.top; + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass http://aktv_stream.m16tv.cfd; # 替换为相对路径 - sub_filter 'https://aktv.top/AKTV/stream/' '/AKTV/stream/'; + sub_filter 'http://aktv_stream.m16tv.cfd/AKTV/stream/' '/AKTV/stream/'; sub_filter_once off; sub_filter_types application/vnd.apple.mpegurl text/plain; @@ -445,31 +712,58 @@ http { # 针对 .ts 和 .aac 文件的特殊缓存设置 location ~* \.(ts|aac)$ { - proxy_pass https://aktv.top; # 替换为您的源站地址 + proxy_pass http://aktv_stream.m16tv.cfd; # 替换为您的源站地址 proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 expires 60s; # 设置浏览器端缓存 60 秒 } + + # 针对 m3u 文件内容修改 + location ~ \.m3u$ { + 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 http://aktv_stream.m16tv.cfd; + + # 替换为相对路径 + sub_filter 'http://aktv_stream.m16tv.cfd' 'http://$host:20008'; + sub_filter 'AKTV.m3u8' 'AKTV.m3u8?token=$arg_token'; + sub_filter_once off; + sub_filter_types application/vnd.apple.mpegurl text/plain; + + # 解压 gzip 压缩内容(如源站启用了压缩) + gzip off; + proxy_set_header Accept-Encoding ""; + } } server { - listen 30001; - listen [::]:30001; + 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 User-Agent "TiviMate/5.1.0"; - proxy_set_header Referer "https://www.stream-link.org/"; - proxy_set_header Host www.stream-link.org; - proxy_set_header Accept "*/*"; # 允许所有类型的内容 - proxy_set_header Connection "keep-alive"; + # 屏蔽 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; # 代理头设置 - #proxy_set_header X-Real-IP $remote_addr; # 传递客户端真实 IP + 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 协议 @@ -487,50 +781,177 @@ http { # 默认 location 配置 location / { - proxy_pass https://www.stream-link.org; # 替换为您的源站地址 - } + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } - # 针对 m3u 文件内容修改 - location ~ \.m3u$ { - proxy_pass https://www.stream-link.org; + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } - # 替换为相对路径 - sub_filter 'https://sc2025.stream-link.org' 'http://$host:30002'; - sub_filter_once off; - #sub_filter_types application/vnd.apple.mpegurl text/plain; + proxy_pass https://cdn8.zone.id; # 替换为您的源站地址 + } - # 解压 gzip 压缩内容(如源站启用了压缩) - gzip off; - proxy_set_header Accept-Encoding ""; - } + # 针对 .ts 和 .aac 文件的特殊缓存设置 + location ~* \.(ts|aac)$ { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://cdn8.zone.id; # 替换为您的源站地址 + proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒 + expires 60s; # 设置浏览器端缓存 60 秒 + } } - server { - listen 30002; - listen [::]:30002; - server_name cdn.1678520.xyz; + server { + listen 20010; + listen [::]:20010; + server_name cdn.1678520.xyz; # 替换为您的域名 - location / { - proxy_pass https://sc2025.stream-link.org; - proxy_set_header Host sc2025.stream-link.org; - proxy_set_header User-Agent "TiviMate/5.1.0"; - proxy_set_header Referer "https://sc2025.stream-link.org/"; - proxy_redirect ~https?://[^/]+(/.*) http://$host:30003$1; - } - } + # 自定义响应头:缓存命中状态和剩余缓存时间 + add_header X-Cache-Status $upstream_cache_status; + add_header X-Cache-TTL $upstream_http_x_cache_ttl; - server { - listen 30003; - listen [::]:30003; - 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; - location / { - proxy_pass https://live-edge-06.stream-link.org; - proxy_set_header Host live-edge-06.stream-link.org; - proxy_set_header User-Agent "TiviMate/5.1.0"; - proxy_set_header Referer "https://live-edge-06.stream-link.org/"; - } - } + # 代理头设置 + 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 / { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://mytv.101.qzz.io; # 替换为您的源站地址 + proxy_set_header Host mytv.101.qzz.io; # 确保请求的 Host 匹配 Cloudflare 配置 + } + + # /o12/ 子目录 + location /o12/ { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + proxy_pass https://o12.1678520.xyz/; + proxy_set_header Host o12.1678520.xyz; # 确保请求的 Host 匹配 Cloudflare 配置 + } + + # /hw/ 子目录 + location /hw/ { + if ($auth_ok = 0) { + return 302 https://cdn.1678520.xyz/403?mytv; + } + + if ($arg_token) { + add_header Set-Cookie "token=$arg_token; Path=/"; + return 302 $redirect_uri; + } + + 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; + + # 屏蔽 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; + + # 代理头设置 + 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.16899.ggff.net; + + # 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 { + 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://cdn.16899.ggff.net/mytv.m3u; # 替换为您的源站地址 + sub_filter '服务器ip' '$host'; + sub_filter '.m3u8' '.m3u8?token=$arg_token'; + sub_filter 'smtm3u8' 'smtm3u8&token=$arg_token'; + sub_filter_once off; # 替换所有匹配项 + sub_filter_types *; # 对所有 MIME 类型进行替换 + + # 解压 gzip 压缩内容(如源站启用了压缩) + gzip off; + proxy_set_header Accept-Encoding ""; + } + } }