Last active
September 11, 2023 15:52
-
-
Save dPacc/0571db8778c00754fcbe8a40b9335839 to your computer and use it in GitHub Desktop.
EC2 Mutliple Instance for the same app with Load Balancing
This file contains hidden or 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
``` | |
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