File size: 1,560 Bytes
3153063
9df8967
 
3153063
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9df8967
 
 
 
 
 
 
3153063
 
 
 
 
 
 
 
 
 
 
 
 
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
# Front door on the Space's port. WebSocket upgrades are game players (Captain of Sea server on
# 27777), /cos2/ is the game's error reports (8001); every other request is the Kimi proxy (uvicorn
# on 8000), exactly as before.
worker_processes 1;
pid /tmp/nginx.pid;
error_log /dev/stderr warn;

events { worker_connections 1024; }

http {
    access_log off;
    client_body_temp_path /tmp/nginx_body;
    proxy_temp_path /tmp/nginx_proxy;
    fastcgi_temp_path /tmp/nginx_fastcgi;
    uwsgi_temp_path /tmp/nginx_uwsgi;
    scgi_temp_path /tmp/nginx_scgi;

    map $http_upgrade $backend {
        default        http://127.0.0.1:8000;
        ~*^websocket$  http://127.0.0.1:27777;
    }
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    server {
        listen 7860;
        client_max_body_size 50m;

        # The game's error reports (reports.py).
        location /cos2/ {
            proxy_pass http://127.0.0.1:8001;
            proxy_http_version 1.1;
            proxy_set_header X-Forwarded-For $http_x_forwarded_for;
        }

        location / {
            proxy_pass $backend;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
            # Long chats stream (SSE) and sailors stay for hours: no buffering, long timeouts.
            proxy_buffering off;
            proxy_read_timeout 3600s;
            proxy_send_timeout 3600s;
        }
    }
}