mirror of
https://github.com/rad168/iptv.git
synced 2025-12-24 02:34:59 +08:00
1002 lines
33 KiB
Nginx Configuration File
1002 lines
33 KiB
Nginx Configuration File
user nginx;
|
||
worker_processes auto;
|
||
pcre_jit on;
|
||
|
||
error_log /var/log/nginx/error.log warn;
|
||
include /etc/nginx/modules/*.conf;
|
||
|
||
events {
|
||
worker_connections 1024; # 提高连接数上限
|
||
multi_accept on; # 允许多连接同时接受
|
||
}
|
||
|
||
http {
|
||
include /etc/nginx/mime.types;
|
||
default_type application/octet-stream;
|
||
sendfile on;
|
||
tcp_nopush on;
|
||
tcp_nodelay on;
|
||
keepalive_timeout 65;
|
||
types_hash_max_size 2048;
|
||
|
||
# 缓存路径配置
|
||
proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=my_cache:10m max_size=100m inactive=24h use_temp_path=off;
|
||
|
||
# 日志格式
|
||
log_format main '$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 main;
|
||
|
||
# 禁用nginx版本信息
|
||
server_tokens off;
|
||
|
||
# gzip 设置(可按需启用)
|
||
gzip on;
|
||
gzip_vary on;
|
||
|
||
# 虚拟主机配置(如需启用则取消注释)
|
||
#include /etc/nginx/http.d/*.conf;
|
||
|
||
# 定义 token 来源优先级:URL > Cookie
|
||
map $arg_token $token_to_check {
|
||
default $cookie_token;
|
||
~.+ $arg_token;
|
||
}
|
||
|
||
# 定义允许的 token 列表(把第50行的"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;
|
||
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 cdn.16899.ggff.net; # 确保请求的 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://cdn.16899.ggff.net;
|
||
|
||
}
|
||
|
||
# 针对 .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://cdn.16899.ggff.net; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第二个网站
|
||
server {
|
||
listen 20001;
|
||
listen [::]:20001;
|
||
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 cdn3.163189.xyz; # 确保请求的 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://cdn3.163189.xyz;
|
||
|
||
}
|
||
|
||
# 针对 .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://cdn3.163189.xyz; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第三个网站
|
||
server {
|
||
listen 20002;
|
||
listen [::]:20002;
|
||
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 smt.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 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=/";
|
||
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_pass https://smt.1789.dpdns.org; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第四个网站
|
||
server {
|
||
listen 20003;
|
||
listen [::]:20003;
|
||
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 cdn6.16899.ggff.net; # 确保请求的 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://cdn6.16899.ggff.net;
|
||
|
||
}
|
||
|
||
# 针对 .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://cdn6.16899.ggff.net; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第五个网站
|
||
server {
|
||
listen 20004;
|
||
listen [::]:20004;
|
||
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 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 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://v2h.1789.dpdns.org;
|
||
|
||
}
|
||
|
||
# 针对 .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://v2h.1789.dpdns.org; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第六个网站
|
||
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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://live.tvfix.org; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第七个网站
|
||
server {
|
||
listen 20006;
|
||
listen [::]:20006;
|
||
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 cdn5.163189.xyz; # 确保请求的 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://cdn5.163189.xyz;
|
||
|
||
}
|
||
|
||
# 针对 .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://cdn5.163189.xyz; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第八个网站
|
||
server {
|
||
listen 20007;
|
||
listen [::]:20007;
|
||
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 cdn2.16899.ggff.net; # 确保请求的 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://cdn2.16899.ggff.net;
|
||
|
||
}
|
||
|
||
# 针对 .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://cdn2.16899.ggff.net; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第九个网站
|
||
server {
|
||
listen 20008;
|
||
listen [::]:20008;
|
||
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 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 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass http://aktv_stream.m16tv.cfd;
|
||
|
||
}
|
||
|
||
# 针对 .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 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 20009;
|
||
listen [::]:20009;
|
||
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 cdn8.163189.xyz; # 确保请求的 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=/";
|
||
return 302 $redirect_uri;
|
||
}
|
||
|
||
proxy_pass https://cdn8.163189.xyz;
|
||
|
||
}
|
||
|
||
# 针对 .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.163189.xyz; # 替换为您的源站地址
|
||
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
|
||
expires 60s; # 设置浏览器端缓存 60 秒
|
||
|
||
}
|
||
}
|
||
|
||
# 反代设置:第十一个网站
|
||
server {
|
||
listen 20010;
|
||
listen [::]:20010;
|
||
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; # 支持多级代理
|
||
|
||
# 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 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=/";
|
||
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 配置
|
||
}
|
||
|
||
# /jxiptv/ 子目录
|
||
location /jxiptv/ {
|
||
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://jxiptv.dpdns.org/;
|
||
proxy_set_header Host jxiptv.dpdns.org; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
}
|
||
|
||
# /huya/ 子目录
|
||
location /huya/ {
|
||
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://huya.jxiptv.dpdns.org/;
|
||
proxy_set_header Host huya.jxiptv.dpdns.org; # 确保请求的 Host 匹配 Cloudflare 配置
|
||
}
|
||
|
||
}
|
||
|
||
# 反代设置:订阅链接
|
||
server {
|
||
listen 30000;
|
||
listen [::]:30000;
|
||
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 cdn5.163189.xyz; # 确保请求的 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 /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://cdn5.163189.xyz/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_once off; # 替换所有匹配项
|
||
sub_filter_types *; # 对所有 MIME 类型进行替换
|
||
|
||
# 解压 gzip 压缩内容(如源站启用了压缩)
|
||
gzip off;
|
||
proxy_set_header Accept-Encoding "";
|
||
|
||
}
|
||
}
|
||
|
||
}
|