Skip to content

Instantly share code, notes, and snippets.

@RyanDsilva
Created July 6, 2020 20:27
Show Gist options
  • Save RyanDsilva/ed1cfb49f695c7c1b56a1096a8daf85a to your computer and use it in GitHub Desktop.
Save RyanDsilva/ed1cfb49f695c7c1b56a1096a8daf85a to your computer and use it in GitHub Desktop.
SocketIO + Reverse Proxy + Load Balancing NGINX configuration file
upstream nodejs {
ip_hash;
server localhost:5000;
server localhost:5001;
}
server {
listen 80;
listen [::]:80;
server_name SERVER_IP;
root /home/ryan;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://nodejs/socket.io/;
}
location / {
proxy_pass http://nodejs/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment