Skip to content

Instantly share code, notes, and snippets.

@iampato
Created December 27, 2022 12:31
Show Gist options
  • Select an option

  • Save iampato/49228d177fa828e4e8cef3b018899443 to your computer and use it in GitHub Desktop.

Select an option

Save iampato/49228d177fa828e4e8cef3b018899443 to your computer and use it in GitHub Desktop.
nginx api gateway setup
server {
server_name localhost;
listen 80;
location ~ /users/[12][0-9]+ {
proxy_pass http://localhost:8802;
}
location ~ /products/[12][0-9]+ {
proxy_pass http://localhost:8800;
}
}
@iampato
Copy link
Author

iampato commented Dec 27, 2022

Another version without regex

upstream authentication{
  server 162.243.144.211:8080;
}
upstream shipping {
  server 162.243.144.211:8081;
}
upstream reporting {
  server 162.243.144.211:8082;
}

server {
  listen 443;
  location /auth/ {
        proxy_pass https://authentication/;
  }
  location /shipping/ {
        proxy_pass https://shipping/;
  }
  location /reporting/ {
        proxy_pass https://reporting/;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment