Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nginx thing
server {
listen 80;
server_name myapp.com;
location / {
# Pass off API and socket requests to the app server
proxy_pass http://127.0.0.1:1337;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# See: https://nginx.org/en/docs/http/load_balancing.html
# https://nginx.org/en/docs/http/ngx_http_upstream_module.html
upstream my-app {
least_conn;
server 127.0.0.1:1337; # server 1
server 127.0.0.2:1337; # server 2
server 127.0.0.3:1337; # server 3
}
server {
listen 80;
server_name myapp.com www.myapp.com;
location / {
# Pass off API and socket requests to the app server
proxy_pass http://my-app;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.