title: How to strip context path in nginx, zuul and oauth combined
body: <p>I have Nginx proxy with following configuration:</p>
  
  <pre><code>upstream gateway_server {
    ip_hash; # sticky session on as there will be more than one destination
    server app.server:8080; 
  }
  
  server {
  
    listen                  0.0.0.0:80;
    server_name             my.domain.net;
    root                    /var/www/gateway;
  
    proxy_redirect          off;
    proxy_buffering         off;
    proxy_connect_timeout   5s;
    proxy_read_timeout      120s;
    proxy_next_upstream     error timeout http_502 http_503 http_504;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Forwarded-Host $host;
    proxy_set_header        X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header        Host $host;
    proxy_intercept_errors  on;
  
   location / {
     proxy_pass              http://gateway_server/my-application/;
   }
  
   location /loginPage {
     proxy_pass              http://gateway_server/loginPage;
   }
  
   location ^~ /login {
     proxy_pass              http://gateway_server/login;
   }
  
   location /logout {
     proxy_pass              http://gateway_server/logout;
   }
  
   location /css {
     proxy_pass              http://gateway_server/css;
   }
  
  
   error_page 502 503 504 @maintenance;
   location @maintenance {
       rewrite ^(.*)$          /maintenance.html break;
   } 
  
   error_page 404 /404.html;
   location = /404.html {
     rewrite ^(.*)$          /404.html break;
   }
  
   error_page 500 /500.html;
   location = /500.html {
     rewrite ^(.*)$          /500.html break;
   }
  }
  </code></pre>
  
  <p>The <em>gateway-server</em> is pointing at my zuul proxy, which is a simple SpringBoot Application annotated with <em>@EnableZuulProxy</em>. Routes are configured as follows:</p>
  
  <pre><code># Zuul configuration
  zuul:
    host:
      socket-timeout-millis: 300000 # 5 minutes
    sensitiveHeaders:
    routes:
      my-application:
        path: /my-application/**
        serviceId: my-application
        stripPrefix: false
  </code></pre>
  
  <p><em>my-application</em> is a Spring Boot application combined with angular front-end. Apart from routing, <em>gateway-server</em> is also responsible for authentication - it communicates with out OAuth2 multi provider. When a user is not authenticated, and tries to call <em>my.domain.net</em> Nginx proxies the call to zuul (<em>app.server:8080/my-application/</em>) <em>gateway-server</em> starts Oauth2 protocol, and forwards user to a login page, where one can choose his/hers provider (facebook, google, internal). Whole authentication is managed by spring - I don't do any custom things. After successful login user gets redirected to <strong>my.domain.net/my-application</strong> rather than to <strong>my.domain.net</strong>.
  Do you have any idea which element in my infrastructure adds this context path? Do you have any idea how could I remove it?</p>