Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A simple setup for using a reverse proxy in micro services
upstream exampleone {
server host-ip:3000;
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