From 089a5575d1dda133ba34d4fb00f4fef52a3da0b4 Mon Sep 17 00:00:00 2001 From: core Date: Mon, 15 May 2023 19:13:00 -0400 Subject: [PATCH] build assets with compiling the client --- .gitignore | 4 +++- docker/nginx.conf | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docker/nginx.conf diff --git a/.gitignore b/.gitignore index 752e70c1f6f2d6c54aa501e4e1cc70b23710433d..0b13dbc94863b78db57b0e16a72e4741162c5a53 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ assets/svg/*.png build.ninja .ninja_log api/config.toml -api/.env \ No newline at end of file +api/.env +assets/dist +assets/final \ No newline at end of file diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000000000000000000000000000000000000..d0344db83dda0c77786d22b6a8ced71412f85c92 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,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 + } +} \ No newline at end of file