-
-
Save getsadzeg/170134c0727e3ab6e9f70073c24217ea to your computer and use it in GitHub Desktop.
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
upstream loadbalancer { | |
server localhost:3000; | |
server localhost:3001; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name api.example.com; | |
return 302 https://$server_name$request_uri; | |
} | |
server { | |
# SSL configuration | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; | |
ssl_certificate /etc/ssl/cert.pem; | |
ssl_certificate_key /etc/ssl/key.pem; | |
server_name api.example.com; | |
# Enable gzip compression only for application/json | |
gzip off; | |
gzip_types application/json; | |
gzip_proxied any; | |
gzip_min_length 1000; | |
gzip_vary on; | |
location / { | |
proxy_pass http://loadbalancer; | |
proxy_http_version 1.1; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Server $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; | |
proxy_set_header Host $http_host; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_pass_request_headers on; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment