Files
d1kt/nginx-path-compat.conf

39 lines
1.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Nginx路径兼容配置 - 支持 /api/socket.io 和 /socket.io
# 将此配置添加到你的现有Nginx配置中
# 方法1: 使用正则表达式匹配多种socket.io路径
location ~ ^/(api/)?socket\.io/ {
# 统一转发到后端的标准路径
proxy_pass http://localhost:5001/api/socket.io/;
proxy_http_version 1.1;
# WebSocket握手头
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_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
# 缓冲区设置
proxy_buffering off;
proxy_buffer_size 16k;
proxy_buffers 4 32k;
}
# 方法2: 分别处理两种路径如果方法1不工作
# location = /api/socket.io/ {
# proxy_pass http://localhost:5001/api/socket.io/;
# # ... 其他配置保持不变
# }
#
# location = /socket.io/ {
# proxy_pass http://localhost:5001/api/socket.io/;
# # ... 其他配置保持不变
# }