map $http_host $this_host { "" $host; default $http_host; } map $http_x_forwarded_proto $the_scheme { default $http_x_forwarded_proto; "" $scheme; } map $http_x_forwarded_host $the_host { default $http_x_forwarded_host; "" $this_host; } server { listen 80; listen [::]:80; server_name localhost; set $X_REWRITER_URL $the_scheme://$the_host; location / { if ($http_referer ~* /appserver) { rewrite /(.*) /appserver/$1 last; } # if ($http_referer ~* /products/people/) { # rewrite /(.*) /appserver/$1 last; # } # proxy_set_header Host portals; proxy_pass http://localhost:8081; root /usr/share/nginx/html; index index.html index.htm; } location ~* ^/appserver/ { rewrite /appserver(.*) $1 break; proxy_pass http://localhost:8092; proxy_set_header Accept-Encoding ""; proxy_set_header X-REWRITER-URL $X_REWRITER_URL; # proxy_redirect ~*(.*)/login/(.*) $1/appserver/login/$2; # proxy_redirect ~*(.*)/products/people/(.*) $1/appserver/products/people/$2; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }