Update nginx.conf

This commit is contained in:
rad168
2025-06-16 15:08:17 +08:00
committed by GitHub
parent 837bf57d41
commit 48c911d46c

View File

@@ -487,7 +487,7 @@ http {
# 代理头设置
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 配置
proxy_set_header Host s1.m16tv.cfd; # 确保请求的 Host 匹配 Cloudflare 配置
# SSL 配置
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # 指定 SSL 协议
@@ -505,15 +505,15 @@ http {
# 默认 location 配置
location / {
proxy_pass http://aktv_stream.m16tv.cfd; # 替换为您的源站地址
proxy_pass http://s1.m16tv.cfd; # 替换为您的源站地址
}
# 针对 m3u8 文件内容修改
location ~ \.m3u8$ {
proxy_pass http://aktv_stream.m16tv.cfd;
proxy_pass http://s1.m16tv.cfd;
# 替换为相对路径
sub_filter 'http://aktv_stream.m16tv.cfd/AKTV/stream/' '/AKTV/stream/';
sub_filter 'http://s1.m16tv.cfd/AKTV/stream/' '/AKTV/stream/';
sub_filter_once off;
sub_filter_types application/vnd.apple.mpegurl text/plain;
@@ -524,20 +524,24 @@ http {
# 针对 .ts 和 .aac 文件的特殊缓存设置
location ~* \.(ts|aac)$ {
proxy_pass http://aktv_stream.m16tv.cfd; # 替换为您的源站地址
proxy_pass http://s1.m16tv.cfd; # 替换为您的源站地址
proxy_cache_valid 200 206 60s; # 缓存 .ts 文件 60 秒
expires 60s; # 设置浏览器端缓存 60 秒
}
# 针对 m3u 文件内容修改
location ~ \.m3u$ {
proxy_pass http://aktv_stream.m16tv.cfd;
proxy_pass http://aktv.space;
# 强制标记为纯文本
default_type text/plain;
add_header Content-Type "text/plain; charset=utf-8" always;
add_header Content-Disposition "inline" always;
# 替换为相对路径
sub_filter 'http://aktv_stream.m16tv.cfd' 'http://$host:20008';
sub_filter 'AKTV.m3u8' 'AKTV.m3u8?token=$arg_token';
sub_filter 'https://s1.m16tv.cfd' 'http://$host:20008';
sub_filter_once off;
sub_filter_types application/vnd.apple.mpegurl text/plain;
sub_filter_types *; # 对所有 MIME 类型进行替换
# 解压 gzip 压缩内容(如源站启用了压缩)
gzip off;