Skip to content

Instantly share code, notes, and snippets.

@patrickdawson
Last active March 6, 2019 14:39
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 patrickdawson/441590a4f037ed227c7ab00272a3d635 to your computer and use it in GitHub Desktop.
Save patrickdawson/441590a4f037ed227c7ab00272a3d635 to your computer and use it in GitHub Desktop.
[nginx] Example api config
location /consul {
set $upstream consul;
rewrite ^/consul(.*) /_consul$1 last;
}
location /ui {
set $upstream consul;
rewrite ^(.*)$ /_consul$1 last;
}
location /v1 {
set $upstream consul;
rewrite ^(.*)$ /_consul$1 last;
}
# policy section
#
location /_consul {
internal;
rewrite ^/_consul(.*)$ $1 break;
proxy_pass http://$upstream$1;
}
# Working - all in one
# location /express {
# set $upstream express;
# rewrite ^ / break;
# proxy_pass http://$upstream;
# }
location /express {
set $upstream express;
# rewrite complete uri -> /_express/...
rewrite ^/express(.*)$ /_express$1 last;
}
# Policy section
location /_express {
internal;
set $api_name "express";
rewrite ^/_express(.*)$ $1 break;
proxy_pass http://$upstream$1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment