83 lines
2.6 KiB
Nginx Configuration File
83 lines
2.6 KiB
Nginx Configuration File
server {
|
||
listen ${NGINX_PORT} default_server;
|
||
listen [::]:${NGINX_PORT} default_server;
|
||
server_name _;
|
||
|
||
# 前端资源
|
||
location / {
|
||
root /usr/share/nginx/html;
|
||
index index.html index.htm;
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 后端API代理(backend使用host网络)
|
||
location /prod-api/ {
|
||
proxy_pass http://127.0.0.1:8080/;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
proxy_connect_timeout 600;
|
||
proxy_read_timeout 600;
|
||
proxy_send_timeout 600;
|
||
}
|
||
|
||
# WebSocket支持(用于视频流)
|
||
location /websocket/ {
|
||
proxy_pass http://127.0.0.1:8080/websocket/;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_connect_timeout 7d;
|
||
proxy_send_timeout 7d;
|
||
proxy_read_timeout 7d;
|
||
}
|
||
|
||
# Python推理服务代理(映射到宿主机端口)
|
||
location /python-api/ {
|
||
proxy_pass http://127.0.0.1:8000/;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header X-Forwarded-Proto $scheme;
|
||
}
|
||
|
||
# 视频流代理(HTTP-FLV,backend使用host网络)
|
||
location /live {
|
||
proxy_pass http://127.0.0.1:8866/live;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_set_header Connection "";
|
||
proxy_buffering off;
|
||
proxy_cache off;
|
||
chunked_transfer_encoding off;
|
||
}
|
||
|
||
# 视频流代理(HLS)
|
||
location /hls {
|
||
proxy_pass http://127.0.0.1:8866/hls;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||
proxy_buffering off;
|
||
proxy_cache off;
|
||
}
|
||
|
||
# MinIO使用外部服务,不需要代理
|
||
|
||
# 错误页面配置
|
||
error_page 500 502 503 504 /50x.html;
|
||
location = /50x.html {
|
||
root /usr/share/nginx/html;
|
||
}
|
||
|
||
# 日志配置
|
||
access_log /var/log/nginx/access.log;
|
||
error_log /var/log/nginx/error.log;
|
||
} |