-
-
Save filharvey/1e9bacaf32b4ad7156ad163c639d7720 to your computer and use it in GitHub Desktop.
Nginx config and ubuntu systemd services for hosting multiple game instances on ports 8001 through 8005, proxied from urls like wss://subdomain.domain.io/1 through wss://subdomain.domain.io/5; can also remove the ssl and listen on port 80 instead. The service file is an example, but creating 5 called instance1.service through instance5.service a…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
server { | |
listen 443 ssl; | |
ssl_certificate /srv/certs/fullchain.pem; | |
ssl_certificate_key /srv/certs/privkey.pem; | |
location = /1 { | |
proxy_pass http://127.0.0.1:8001; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
location = /2 { | |
proxy_pass http://127.0.0.1:8002; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
location = /3 { | |
proxy_pass http://127.0.0.1:8003; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
location = /4 { | |
proxy_pass http://127.0.0.1:8004; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
location = /5 { | |
proxy_pass http://127.0.0.1:8005; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection $connection_upgrade; | |
} | |
# etc if needed | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=instance 1 | |
After=network-online.target | |
[Service] | |
Environment=NODE_ENV=production | |
Type=simple | |
User=root | |
WorkingDirectory=/srv | |
ExecStart=/usr/bin/node ./srv/something.js --port 8001 --url 1 | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment