Skip to content

Instantly share code, notes, and snippets.

@giuliocalzolari
Created February 7, 2018 15:05
Show Gist options
  • Save giuliocalzolari/855cf3e8e41b70a1d7bc651c8217283c to your computer and use it in GitHub Desktop.
Save giuliocalzolari/855cf3e8e41b70a1d7bc651c8217283c to your computer and use it in GitHub Desktop.
Using nginx to proxy to an AWS internal ELB
daemon off;
worker_processes auto;
events { worker_connections 1024; }
http {
sendfile on;
server {
### server port and name ###
listen 80 default_server;
server_name _;
resolver 8.8.8.8 valid=10s;
resolver_timeout 10s;
### log files ###
access_log logs/access.log;
error_log logs/error.log;
location / {
set $albinternal "internal-ALB-name-123456789.eu-west-1.elb.amazonaws.com";
proxy_pass http://$albinternal;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
### Set headers ####
proxy_set_header Accept-Encoding "";
proxy_set_header Host $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;
add_header Front-End-Https on;
### By default we don't want to redirect it ####
proxy_redirect off;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment