Skip to content

Instantly share code, notes, and snippets.

@dPacc
Last active September 11, 2023 15:52
Show Gist options
  • Save dPacc/0571db8778c00754fcbe8a40b9335839 to your computer and use it in GitHub Desktop.
Save dPacc/0571db8778c00754fcbe8a40b9335839 to your computer and use it in GitHub Desktop.
EC2 Mutliple Instance for the same app with Load Balancing
```
server {
listen 80;
server_name SUB_DOMAIN.DOMAIN.com;
return 301 https://$host$request_uri;
}
upstream backend {
server EC2_Private_IPv4:APP_PORT; # In-house test server
server EC2_Private_IPv4:APP_PORT; # In-house test server
server EC2_Private_IPv4:APP_PORT; # In-house test server
server EC2_Private_IPv4:APP_PORT; # EC2 production server
}
server {
listen 443 ssl;
server_name api.sudhamrit.org;
ssl_certificate /etc/letsencrypt/live/SUB_DOMAIN.DOMAIN.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/SUB_DOMAIN.DOMAIN.com/privkey.pem; # managed by Certbot
client_max_body_size 20M; # Adjust this to fit your needs. Note the 'M' immediately follows the number.
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
location / {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment