Spaces:
Sleeping
Sleeping
File size: 1,548 Bytes
e2a096c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# 标记是否为 WebSocket 请求
map $http_upgrade $is_websocket {
default 0;
websocket 1;
}
upstream easytier_backend {
server 127.0.0.1:7880;
keepalive 64;
}
server {
listen 7860;
server_name localhost;
# 方式1:内部代理位置(推荐)
location /_ws {
internal; # 只允许内部重写访问
proxy_pass http://easytier_backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $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_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
# 主 location
location / {
# WebSocket 请求内部重写到 /_ws
if ($is_websocket) {
rewrite ^/(.*)$ /_ws/$1?$args last;
}
# 普通 HTTP 请求
root /var/www/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
} |