Skip to content

Instantly share code, notes, and snippets.

@hamishhossack
Created May 4, 2016 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamishhossack/882fe1e15f9fb94f4a20415d54f917df to your computer and use it in GitHub Desktop.
Save hamishhossack/882fe1e15f9fb94f4a20415d54f917df to your computer and use it in GitHub Desktop.
A simple setup for using a reverse proxy in micro services
# EXAMPLEONE
upstream exampleone {
server host-ip:3000;
}
# EXAMPLETWO
upstream exampletwo {
server host-ip:3001;
}
server {
listen 80 default;
listen [::]:80 default;
server_name ~^(?<api>\w+)\.URL\.PATH$;
access_log /var/log/nginx/proxy.access.log;
error_log /var/log/nginx/proxy.error.log;
client_max_body_size 50M;
location / {
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;
proxy_set_header Host $http_x_forwarded_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_connect_timeout 1;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_bind $server_addr;
proxy_pass http://$api;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment