Created
July 3, 2015 13:11
-
-
Save sahilsk/515ee3ff2f014bdf0826 to your computer and use it in GitHub Desktop.
Nginx elb configuration with proxy-protocol enable. ELB doesn't support websocket at layer 7. So, we need to configure it at TCP layer
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
log_format elb_log '$proxy_protocol_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent"'; | |
server { | |
listen 80 proxy_protocol; | |
listen [::]:80 proxy_protocol; | |
server_name localhost; | |
access_log /var/log/nginx/elb-access_http.log elb_log; | |
location / { | |
root /var/www/html; | |
rewrite ^(.*)$ https://$host$1 permanent; | |
index index*.html index.htm; | |
} | |
} | |
server { | |
listen 443 proxy_protocol ssl; | |
listen [::]:443 proxy_protocol ssl; | |
server_name localhost; | |
access_log /var/log/nginx/elb-access_https.log elb_log; | |
ssl on; | |
ssl_certificate /etc/nginx/ssl/cert.crt; | |
ssl_certificate_key /etc/nginx/ssl/cert.key; | |
root /var/www/html; | |
index index.html index.htm index.nginx-debian.html; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
At ELB Side we need to make following changes.
ElB will be used as a passthrough. Packets are secured as traffic falling at our backends will have ssl enabled with valid certificates.
healthcheck:
Listeners: