File size: 1,856 Bytes
330a9be
 
 
 
 
 
 
 
 
 
 
 
1845d7d
 
5425820
 
99c4eb9
 
5425820
f7bafd7
99c4eb9
 
 
 
 
330a9be
 
 
501f6f2
330a9be
 
e1c17ae
db14ade
330a9be
 
 
 
 
8cde708
db14ade
f6e63c2
 
 
330a9be
 
8ed5d49
 
2c53c32
c234ee2
 
 
 
 
 
2d81c1c
 
 
 
 
 
c234ee2
330a9be
 
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
58
59
60
61
62
63
worker_processes auto;
pid /tmp/nginx.pid; # 非特权用户可写

events {
    worker_connections 1024;
}

http {
    # 设置非特权用户可写的临时路径
    client_body_temp_path /tmp/client_body;
    proxy_temp_path       /tmp/proxy_temp;
    fastcgi_temp_path     /tmp/fastcgi_temp;


    #access_log /dev/stdout;
    #error_log /dev/stderr;
    
    include /etc/nginx/mime.types;
    #include /etc/nginx/conf.d/*.conf;

    # 定义 WebSocket 升级映射(更优雅的写法)
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen 7860;
        server_name 0.0.0.0;

        # 根目录反代 8080 (C/C++ 服务)
        location / {
            proxy_pass http://127.0.0.1:8080/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        # /bot 路径反代 8888 (Python 服务)
        location /bot {
            proxy_pass http://127.0.0.1:8888/;
            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;
        }

        
        location /ttyd/ {
            proxy_pass http://127.0.0.1:7681/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            # 核心:解决 WebSocket 断连问题
        proxy_read_timeout 86400s;  # 增加读取超时时间
        proxy_send_timeout 86400s;  # 增加发送超时时间
        
        # 如果你的面板有特定限制,可能需要缓存设置
        proxy_buffering off;       # WebSocket 建议关闭缓冲
        }
    }
}