title: Deploying IdentityServer4 behind reverse proxy
body: <p>We're trying to deploy IdentityServer4 behind a reverse proxy. The discovery document returns local urls e.g.</p>
  
  <pre><code>https://xxx.local/connect/token
  </code></pre>
  
  <p>Where we need </p>
  
  <pre><code>https://xxx.domain.com/connect/token
  </code></pre>
  
  <p>The IdentityServer <a href="http://docs.identityserver.io/en/release/topics/deployment.html" rel="nofollow noreferrer">docs</a> point us to <a href="https://github.com/aspnet/Docs/issues/2384" rel="nofollow noreferrer">this</a> github page. However, when we configure the middleware as described we see no changes.</p>
  
  <pre><code>var options = new ForwardedHeadersOptions
  {
      ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
  };
  options.KnownNetworks.Clear();
  options.KnownProxies.Clear();
  app.UseForwardedHeaders(options);
  </code></pre>
  
  <p>A similar setup is found on <a href="https://github.com/IdentityServer/IdentityServer4/issues/324" rel="nofollow noreferrer">this</a> github page. The presented solution uses nginx, so perhaps our iis config is off.</p>
  
  <p>In IIS for the proxy:</p>
  
  <p><a href="https://i.stack.imgur.com/kBn5G.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kBn5G.png" alt="enter image description here"></a></p>
  
  <pre><code>&lt;serverVariables&gt;
       &lt;set name="HTTP_X_ORIGINAL_REMOTE_ADDR" value="{REMOTE_ADDR}" /&gt;
       &lt;set name="HTTP_X_FORWARDED_PROTO" value="https" /&gt;
  &lt;/serverVariables&gt;
  </code></pre>
  
  <p>Any help would be appreciated.</p>