This commit is contained in:
孙小云 2025-12-08 19:45:17 +08:00
parent 9e2efec81b
commit 765abf7509
1 changed files with 21 additions and 4 deletions

View File

@ -5,6 +5,15 @@ server {
location / {
root /opt/dist;
index index.html index.htm;
}
# 转发 ZLMediaKit 接口(如 /index/api/webrtc
location ^~ /index/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://polaris-media:80;
}
location /record_proxy/{
proxy_set_header Host $http_host;
@ -30,10 +39,18 @@ server {
sub_filter "http://$original_host:80/index/api/downloadFile" "mediaserver/api/downloadFile";
sub_filter "https://$original_host/index/api/downloadFile" "mediaserver/api/downloadFile";
sub_filter "https://$original_host:443/index/api/downloadFile" "mediaserver/api/downloadFile";
sub_filter "http://$original_host/mp4_record" "mp4_record";
sub_filter "http://$original_host:80/mp4_record" "mp4_record";
sub_filter "https://$original_host/mp4_record" "mp4_record";
sub_filter "https://$original_host:443/mp4_record" "mp4_record";
# 回放/录像走真实host:port避免生成无端口的ws地址
sub_filter "http://$original_host/mp4_record" "$scheme://$http_host/mp4_record";
sub_filter "http://$original_host:80/mp4_record" "$scheme://$http_host/mp4_record";
sub_filter "https://$original_host/mp4_record" "$scheme://$http_host/mp4_record";
sub_filter "https://$original_host:443/mp4_record" "$scheme://$http_host/mp4_record";
# 播放地址使用真实访问的host包含端口避免返回裸IP导致404
sub_filter "http://$original_host/rtp/" "$scheme://$http_host/rtp/";
sub_filter "http://$original_host:80/rtp/" "$scheme://$http_host/rtp/";
sub_filter "ws://$original_host/rtp/" "ws://$http_host/rtp/";
sub_filter "ws://$original_host:80/rtp/" "ws://$http_host/rtp/";
sub_filter "http://$original_host/index/api/webrtc" "$scheme://$http_host/index/api/webrtc";
sub_filter "http://$original_host:80/index/api/webrtc" "$scheme://$http_host/index/api/webrtc";
# 设置为off表示替换所有匹配项而不仅仅是第一个
sub_filter_once off;