~starkingdoms/starkingdoms

ref: e63e7423514ab61346a5feab69bf6f0e349c816b starkingdoms/docker/nginx.conf -rw-r--r-- 2.4 KiB
e63e7423 — ghostlyzsh Merge branch 'master' of https://gitlab.com/starkingdoms.tk/starkingdoms.tk 2 years ago
                                                                                
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
# This is the nginx config that we (starkingdoms) use in production.
# To use this for yourself, replace `YOURDOMAIN` with your domain (ie: starkingdoms.io, bleeding.starkingdoms.io, etc)
# and replace YOURSERVERIP with the IP that the server is hosted on (for local, use 127.0.0.1)
# Ports are the same as the ones deployed by the scripts in /ansible/.
# You can use this as a guide to write your own config. Be aware that the game will not function very well if there is
# high CPU usage on the proxy server, as nginx will struggle to proxy the websocket connection.
# Put this on an at-least-semi-decent server.
# Game pings, game stream and static assets are on the primary domain (ex: bleeding.starkingdoms.io)
server {
        server_name YOURDOMAIN;

        # Static assets should be routed to the nginx container which can handle the traffic
        location / {
                proxy_set_header Host $host;    # Very important (security, logins will break without this), do not remove
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://YOURSERVERIP:3206; # Web port is 3206 with the provided ansible files
        }

        # Websockets should be upgraded and forwarded to the game server
        location /ws {
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_http_version 1.1;
                proxy_set_header Connection "Upgrade";
                proxy_set_header Upgrade $http_upgrade;
                proxy_pass http://YOURSERVERIP:3204; # Game server is 3204 with the provided ansible files
        }
        # Pings to the game server should be routed there too
        location /ping {
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://YOURSERVERIP:3204;
        }
}
# API is on a secondary domain (api.bleeding.starkingdoms.io)
server {
        server_name api.YOURDOMAIN.COM;

        location / {
                proxy_set_header Host $host;                                    # Very important (security), do not remove
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    # Very important (security), do not remove
                proxy_pass http://YOURSERVERIP:3205; # API server is 3205 with the provided ansible files
        }
}