mirror of
https://github.com/rad168/iptv.git
synced 2026-11-06 06:36:45 +08:00
Refactor nginx.conf for better readability
This commit is contained in:
1 parent
36a0a29d0f
commit
730d73ac0f
1 file changed
+112
-134
+112
-134
@@ -91,22 +91,22 @@ 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;
|
||||
# 屏蔽 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 X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||||
proxy_set_header Host cdn.veryfast.filegear-sg.me; # 确保请求的 Host 匹配 Cloudflare 配置
|
||||
|
||||
# SSL 配置
|
||||
# SSL 配置
|
||||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||||
@@ -117,10 +117,10 @@ http {
|
||||
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 秒
|
||||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||||
expires 5s; # 设置浏览器端缓存 5 秒
|
||||
|
||||
# 默认 location 配置
|
||||
# 默认 location 配置
|
||||
location / {
|
||||
if ($auth_ok = 0) {
|
||||
return 302 https://cdn5.163189.xyz/403/?mytv;
|
||||
@@ -160,22 +160,22 @@ 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;
|
||||
# 屏蔽 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 X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||||
proxy_set_header Host cdn3.veryfast.filegear-sg.me; # 确保请求的 Host 匹配 Cloudflare 配置
|
||||
|
||||
# SSL 配置
|
||||
# SSL 配置
|
||||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||||
@@ -186,10 +186,10 @@ http {
|
||||
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 秒
|
||||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||||
expires 5s; # 设置浏览器端缓存 5 秒
|
||||
|
||||
# 默认 location 配置
|
||||
# 默认 location 配置
|
||||
location / {
|
||||
if ($auth_ok = 0) {
|
||||
return 302 https://cdn5.163189.xyz/403/?mytv;
|
||||
@@ -229,22 +229,22 @@ 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;
|
||||
# 屏蔽 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 X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||||
proxy_set_header Host smt.veryfast.filegear-sg.me; # 确保请求的 Host 匹配 Cloudflare 配置
|
||||
|
||||
# SSL 配置
|
||||
# SSL 配置
|
||||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||||
@@ -255,10 +255,10 @@ http {
|
||||
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 秒
|
||||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||||
expires 5s; # 设置浏览器端缓存 5 秒
|
||||
|
||||
# 默认 location 配置
|
||||
# 默认 location 配置
|
||||
location / {
|
||||
if ($auth_ok = 0) {
|
||||
return 302 https://cdn5.163189.xyz/403/?mytv;
|
||||
@@ -907,87 +907,65 @@ http {
|
||||
|
||||
}
|
||||
|
||||
#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 cdn.1678520.xyz;
|
||||
|
||||
# 自定义响应头:缓存命中状态和剩余缓存时间
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
add_header X-Cache-TTL $upstream_http_x_cache_ttl;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_ssl_verify off;
|
||||
|
||||
# 固定请求头
|
||||
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";
|
||||
# ===== 通用请求头 =====
|
||||
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 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;
|
||||
|
||||
# 默认缓存配置
|
||||
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://www.stream-link.org; # 替换为您的源站地址
|
||||
}
|
||||
|
||||
# 针对 m3u 文件内容修改
|
||||
# m3u订阅文件
|
||||
location ~ \.m3u$ {
|
||||
proxy_pass https://www.stream-link.org;
|
||||
proxy_set_header Host www.stream-link.org;
|
||||
|
||||
# 替换为相对路径
|
||||
sub_filter 'https://sc2026.stream-link.org' 'http://$host:30002';
|
||||
# 把源里的播放域名改写成自己
|
||||
sub_filter 'https://sc2026.stream-link.org' 'http://$host:30001';
|
||||
sub_filter_once off;
|
||||
#sub_filter_types application/vnd.apple.mpegurl text/plain;
|
||||
|
||||
# 解压 gzip 压缩内容(如源站启用了压缩)
|
||||
gzip off;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
proxy_intercept_errors on;
|
||||
error_page 301 302 307 = @redirect;
|
||||
}
|
||||
|
||||
# 播放请求
|
||||
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;
|
||||
}
|
||||
|
||||
# 自动跟随跳转
|
||||
location @redirect {
|
||||
set $redirect_url $upstream_http_location;
|
||||
|
||||
# 处理相对跳转
|
||||
if ($redirect_url ~ "^/") {
|
||||
set $redirect_url https://$proxy_host$redirect_url;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 30002;
|
||||
listen [::]:30002;
|
||||
server_name cdn.1678520.xyz;
|
||||
|
||||
location / {
|
||||
proxy_pass https://sc2026.stream-link.org;
|
||||
proxy_set_header Host sc2026.stream-link.org;
|
||||
proxy_set_header User-Agent "TiviMate/5.1.0";
|
||||
proxy_set_header Referer "https://sc2026.stream-link.org/";
|
||||
proxy_redirect ~https?://[^/]+(/.*) http://$host:30003$1;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 30003;
|
||||
listen [::]:30003;
|
||||
server_name cdn.1678520.xyz;
|
||||
|
||||
location / {
|
||||
proxy_pass https://live-edge-01.stream-link.org;
|
||||
proxy_set_header Host live-edge-01.stream-link.org;
|
||||
proxy_set_header User-Agent "TiviMate/5.1.0";
|
||||
proxy_set_header Referer "https://live-edge-01.stream-link.org/";
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 30000;
|
||||
@@ -998,22 +976,22 @@ 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;
|
||||
# 屏蔽 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 X-Forwarded-For $proxy_add_x_forwarded_for; # 支持多级代理
|
||||
proxy_set_header Host cdn.veryfast.filegear-sg.me;
|
||||
|
||||
# SSL 配置
|
||||
# SSL 配置
|
||||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
|
||||
proxy_ssl_ciphers HIGH:!aNULL:!MD5; # 设置加密套件
|
||||
proxy_ssl_verify off; # 忽略上游服务器证书验证
|
||||
@@ -1024,10 +1002,10 @@ http {
|
||||
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 秒
|
||||
proxy_ignore_headers Cache-Control Expires; # 忽略上游响应的缓存控制头
|
||||
expires 5s; # 设置浏览器端缓存 5 秒
|
||||
|
||||
# 默认 location 配置
|
||||
# 默认 location 配置
|
||||
location /mytv.m3u {
|
||||
if ($auth_ok = 0) {
|
||||
return 302 https://cdn5.163189.xyz/403/?mytv;
|
||||
@@ -1038,17 +1016,17 @@ http {
|
||||
}
|
||||
|
||||
proxy_pass http://cdn.veryfast.filegear-sg.me/mytv.m3u; # 替换为您的源站地址
|
||||
sub_filter '服务器ip' '$host';
|
||||
sub_filter '.m3u8' '.m3u8?token=$arg_token';
|
||||
sub_filter 'smt3.2.1.php?' 'smt3.2.1.php?token=$arg_token&';
|
||||
sub_filter '?u=test' '&u=test';
|
||||
sub_filter '?163189' '?163189&token=$arg_token';
|
||||
sub_filter_once off; # 替换所有匹配项
|
||||
sub_filter '服务器ip' '$host';
|
||||
sub_filter '.m3u8' '.m3u8?token=$arg_token';
|
||||
sub_filter 'smt3.2.1.php?' 'smt3.2.1.php?token=$arg_token&';
|
||||
sub_filter '?u=test' '&u=test';
|
||||
sub_filter '?163189' '?163189&token=$arg_token';
|
||||
sub_filter_once off; # 替换所有匹配项
|
||||
sub_filter_types *; # 对所有 MIME 类型进行替换
|
||||
|
||||
# 解压 gzip 压缩内容(如源站启用了压缩)
|
||||
gzip off;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
gzip off;
|
||||
proxy_set_header Accept-Encoding "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user