2024-09-01 16:41:05 +08:00
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
default upgrade;
|
|
|
|
'' close;
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:36:16 +08:00
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
listen [::]:80;
|
|
|
|
server_name localhost;
|
|
|
|
|
|
|
|
location / {
|
|
|
|
root /etc/nginx/html;
|
|
|
|
index index.html index.htm;
|
|
|
|
try_files $uri /index.html;
|
|
|
|
}
|
|
|
|
|
2024-09-01 16:41:05 +08:00
|
|
|
# 后端跨域请求
|
2024-08-28 10:36:16 +08:00
|
|
|
location ~/api/ {
|
2024-09-01 16:41:05 +08:00
|
|
|
proxy_pass http://192.168.3.98:8200;
|
|
|
|
}
|
|
|
|
|
|
|
|
# 配置WebSocket
|
|
|
|
location ~/ws/ {
|
|
|
|
# WebSocket 代理配置
|
|
|
|
proxy_pass http://192.168.3.98:8200; # WebSocket 服务器地址和端口
|
|
|
|
proxy_http_version 1.1; # 使用 HTTP 1.1 版本
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_read_timeout 600s; # 保持连接的超时时间,根据需要调整
|
|
|
|
proxy_redirect off; # 关闭重定向
|
2024-08-28 10:36:16 +08:00
|
|
|
}
|
|
|
|
|
2024-09-01 16:41:05 +08:00
|
|
|
# mock 跨域
|
|
|
|
location ~/mock/ {
|
|
|
|
proxy_pass http://192.168.3.98:8200;
|
2024-08-28 10:36:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
error_page 404 404.html;
|
|
|
|
|
|
|
|
location = /50x.html {
|
|
|
|
root html;
|
|
|
|
}
|
|
|
|
}
|