title: IdentityServer 4 : connect/authorize/callback address not found behind Nginx reverse proxy
body: <p>hi i am new in identityserver 4 and trying to deploy my test project on the server.
  i have client ids and api project which are dockerized. after playing around with identity server 4 and nginx reverse proxy configuration finally every thing work properly except the redirect callback after login.</p>
  <h4>STORY : </h4>
  in my reverse proxy i have 3 upstreams as follow : <br/>
  <ol>
  <li>Client APP which is accessible by url https ://xxx.com/ itself. and it is configured as</li>
  </ol>
  <blockquote>
  <pre><code>   location / {
                      proxy_pass http ://Client;
                      proxy_buffering off;
                      proxy_set_header X-Real-IP $remote_addr;
                      proxy_set_header X-Forwarded-Host $host;
                      proxy_set_header X-Forwarded-Port $server_port;
      
                      fastcgi_buffers 16 16k;
                      fastcgi_buffer_size 32k;
      
              }
  </code></pre>
  </blockquote>
  <p>i added the below code to pipe line to set the original url. without this i got invalid redirect uri (in configuration setup i set it with proper address but in error it shows it trying to redirect to https ://Client/signin-iodc)</p>
  <pre><code>app.Use(async (ctx, next) =&gt;
  {
      ctx.Request.Scheme = &quot;https&quot;;
      ctx.Request.Host = new HostString(&quot;xxx.com&quot;);
      
      await next();
  });
  </code></pre>
  <ol start="2">
  <li>Identity Server 4 that is accessible by base URL https ://xxx.com/identity and also i can get the configuration properly with proper addresses. it is configured as</li>
  </ol>
  <blockquote>
  <pre><code>location /identity/ {
                  proxy_pass http ://Identity/;
  
                  proxy_buffering off;
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header X-Forwarded-Host $host;
                  proxy_set_header X-Forwarded-Port $server_port;
  
                  fastcgi_buffers 16 16k;
                  fastcgi_buffer_size 32k;
  
          }
  </code></pre>
  </blockquote>
  <p>same here added the below code to pipe line to set the original url for Identity server</p>
  <pre><code>app.Use(async (ctx, next) =&gt;
  {
      ctx.Request.Scheme = &quot;https&quot;;
      ctx.Request.Host = new HostString(&quot;xxx.com/identity/&quot;);
      
      await next();
  });
  </code></pre>
  <p>without this in openid-configuration i had the wrong addresses like https ://identity/connect....</p>
  <ol start="3">
  <li>Api resource which is not the problem here and it accessible on url https ://xxx.com/api/....</li>
  </ol>
  <hr/>
  <h6>UPSTREAMS:</h6>
  <pre><code>upstream Client{
          zone Client 64k;
          server localhost:5001;
  }
  
  
  
  upstream Identity{
  
          zone Identity 64k;
          server localhost:9001;
  }
  </code></pre>
  <hr/>
  <h4>Problem:</h4>
  now with this config everything works. i redirect to login page with proper url 
  <blockquote>
  <p>https ://xxx.com/identity/Account/Login?ReturnUrl=%......</p>
  </blockquote>
  <p>but after login it should go for</p>
  <blockquote>
  <p>https ://xxx.com/identity/connect/authorize/callback?client_id=</p>
  </blockquote>
  <p>but it redirects to</p>
  <blockquote>
  <p>https ://xxx.com/connect/authorize/callback?client_id=</p>
  </blockquote>
  <p>which not valid and obviously i get page can’t be found.</p>
  <p>if i add identity to the same url it works properly and go to the home page of client since i have cookies and authorized.</p>
  <p>i dont know if i messed up something here by adding the middle-ware for origin url or i missed some configuration in nginx.</p>