Update nginx.conf

This commit is contained in:
rad168 authored and GitHub committed 2026-03-14 23:03:25 +08:00
1 parent e292d37156
commit b054ffcd54
1 file changed
+179 -46
+179 -46
View File
@@ -855,10 +855,10 @@ http {
# 默认缓存配置(测试区网站未设置ts文件缓存)
proxy_cache cache_zone; # 使用指定的缓存区域
proxy_cache_lock on; # 启用缓存锁
proxy_cache_valid 200 206 5s; # 默认对 200 和 206 状态码缓存 5 秒
proxy_cache_valid 200 206 3s; # 默认对 200 和 206 状态码缓存 3 秒
proxy_cache_methods GET HEAD; # 仅缓存 GET 和 HEAD 请求
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
expires 5s; # 设置浏览器端缓存 5 秒
expires 3s; # 设置浏览器端缓存 5 秒
# 默认 location 配置
location / {
@@ -905,65 +905,198 @@ http {
proxy_set_header Host cdn9.veryfast.filegear-sg.me; # 确保请求的 Host 匹配 Cloudflare 配置
}
# /cdn11/ 子目录
location /cdn11/ {
if ($auth_ok = 0) {
return 302 https://cdn5.163189.xyz/403/?mytv;
}
if ($arg_token) {
add_header Set-Cookie "token=$arg_token; Path=/";
return 302 $redirect_uri;
}
proxy_pass https://cdn11.163189.xyz/;
proxy_set_header Host cdn11.163189.xyz; # 确保请求的 Host 匹配 Cloudflare 配置
sub_filter 'https://cdn11.163189.xyz' 'http://$host:20010/cdn11';
sub_filter_once off; # 替换所有匹配项
sub_filter_types application/vnd.apple.mpegurl text/plain;
# 解压 gzip 压缩内容(如源站启用了压缩)
gzip off;
proxy_set_header Accept-Encoding "";
}
# /cdn12/ 子目录
location /cdn12/ {
if ($auth_ok = 0) {
return 302 https://cdn5.163189.xyz/403/?mytv;
}
if ($arg_token) {
add_header Set-Cookie "token=$arg_token; Path=/";
return 302 $redirect_uri;
}
proxy_pass https://cdn12.178.indevs.in/;
proxy_set_header Host cdn12.178.indevs.in; # 确保请求的 Host 匹配 Cloudflare 配置
sub_filter 'https://cdn12.178.indevs.in' 'http://$host:20010/cdn12';
sub_filter_once off; # 替换所有匹配项
sub_filter_types application/vnd.apple.mpegurl text/plain;
# 解压 gzip 压缩内容(如源站启用了压缩)
gzip off;
proxy_set_header Accept-Encoding "";
}
# /cdn13/ 子目录
location /cdn13/ {
if ($auth_ok = 0) {
return 302 https://cdn5.163189.xyz/403/?mytv;
}
if ($arg_token) {
add_header Set-Cookie "token=$arg_token; Path=/";
return 302 $redirect_uri;
}
proxy_pass https://cdn13.178.indevs.in/;
proxy_set_header Host cdn13.178.indevs.in; # 确保请求的 Host 匹配 Cloudflare 配置
sub_filter 'https://cdn13.178.indevs.in' 'http://$host:20010/cdn13';
sub_filter_once off; # 替换所有匹配项
sub_filter_types application/vnd.apple.mpegurl text/plain;
# 解压 gzip 压缩内容(如源站启用了压缩)
gzip off;
proxy_set_header Accept-Encoding "";
}
# /cdn15/ 子目录
location /cdn15/ {
if ($auth_ok = 0) {
return 302 https://cdn5.163189.xyz/403/?mytv;
}
if ($arg_token) {
add_header Set-Cookie "token=$arg_token; Path=/";
return 302 $redirect_uri;
}
proxy_pass https://cdn15.163189.xyz/;
proxy_set_header Host cdn15.163189.xyz; # 确保请求的 Host 匹配 Cloudflare 配置
sub_filter 'https://cdn15.163189.xyz' 'http://$host:20010/cdn15';
sub_filter_once off; # 替换所有匹配项
sub_filter_types application/vnd.apple.mpegurl text/plain;
# 解压 gzip 压缩内容(如源站启用了压缩)
gzip off;
proxy_set_header Accept-Encoding "";
}
}
#stream-link反代配置
resolver 1.1.1.1 ipv6=off valid=30s;
server {
listen 30001;
listen [::]:30001;
server_name cdn.1678520.xyz;
listen 30001;
listen [::]:30001;
server_name cdn5.163189.xyz;
proxy_ssl_server_name on;
proxy_ssl_verify off;
# ================== 基础优化 ==================
proxy_ssl_server_name on;
proxy_ssl_verify off;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
chunked_transfer_encoding on;
# ===== 通用请求头 =====
proxy_set_header User-Agent "TiviMate/5.1.0";
proxy_set_header Referer "https://www.stream-link.org/";
proxy_set_header Accept "*/*";
proxy_set_header Connection "keep-alive";
proxy_set_header User-Agent "TiviMate/5.1.0";
proxy_set_header Accept "*/*";
proxy_set_header Connection "keep-alive";
# m3u订阅文件
location ~ \.m3u$ {
proxy_pass https://www.stream-link.org;
proxy_set_header Host www.stream-link.org;
# ================== m3u订阅文件 ==================
location ~ \.m3u$ {
# 把源里的播放域名改写成自己
sub_filter 'https://sc2026.stream-link.org' 'http://$host:30001';
sub_filter_once off;
proxy_pass https://www.stream-link.org;
gzip off;
proxy_set_header Accept-Encoding "";
proxy_intercept_errors on;
error_page 301 302 307 = @redirect;
}
proxy_set_header Host www.stream-link.org;
proxy_set_header User-Agent "TiviMate/5.1.0";
# 播放请求
location / {
proxy_pass https://sc2026.stream-link.org;
proxy_set_header Host sc2026.stream-link.org;
proxy_intercept_errors on;
error_page 301 302 307 = @redirect;
}
sub_filter_once off;
sub_filter_types *;
# 自动跟随跳转
location @redirect {
set $redirect_url $upstream_http_location;
sub_filter 'https://' 'http://$host:30001/p/https://';
# 处理相对跳转
if ($redirect_url ~ "^/") {
set $redirect_url https://$proxy_host$redirect_url;
}
gzip off;
proxy_pass $redirect_url;
proxy_set_header Host $proxy_host;
proxy_set_header User-Agent "TiviMate/5.1.0";
proxy_set_header Referer $redirect_url;
proxy_ssl_server_name on;
proxy_intercept_errors on;
error_page 301 302 307 = @redirect;
}
proxy_set_header Accept-Encoding "";
}
# ================== 核心 /p/ 动态反代 ==================
location ^~ /p/ {
resolver 1.1.1.1 ipv6=off;
set $target $request_uri;
if ($target ~ "^/p/(https?://[^/]+)(/.*)$") {
set $upstream_host $1;
set $upstream_path $2;
}
if ($upstream_host = "") {
return 404;
}
proxy_pass $upstream_host$upstream_path;
proxy_set_header Host $proxy_host;
proxy_set_header User-Agent "TiviMate/5.1.0";
proxy_ssl_server_name on;
proxy_set_header Referer https://www.stream-link.org/;
gzip off;
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types *;
sub_filter '/2600_' 'http://$host:30001/p/$upstream_host/2600_';
sub_filter 'https://' 'http://$host:30001/p/https://';
proxy_intercept_errors on;
error_page 301 302 307 = @redirect;
}
# ================== 内部跳转处理 ==================
location @redirect {
set $redirect_url $upstream_http_location;
if ($redirect_url ~ "^/") {
set $redirect_url https://$proxy_host$redirect_url;
}
set $redirect_url /p/$redirect_url;
return 302 $redirect_url;
}
# ================== 默认拒绝其他请求 ==================
location / {
return 404;
}
}