title: Error connecting to http://localhost:8000/.well-known/openid-configuration/jwks. Object reference not set to an instance of an object
body: <p>I host my identity server use address  <a href="http://10.2.5.90:8000" rel="nofollow noreferrer">http://10.2.5.90:8000</a> and use nginx map <a href="https://10.2.5.90:8888" rel="nofollow noreferrer">https://10.2.5.90:8888</a> to <a href="http://10.2.5.90:8000" rel="nofollow noreferrer">http://10.2.5.90:8000</a>. </p>
  
  <p>When i tried to request discovery document like <a href="http://docs.identityserver.io/en/latest/quickstarts/1_client_credentials.html" rel="nofollow noreferrer">quickstart</a> in client, <strong>"Error connecting to <a href="http://localhost:8000/.well-known/openid-configuration/jwks" rel="nofollow noreferrer">http://localhost:8000/.well-known/openid-configuration/jwks</a>. Object reference not set to an instance of an object.."</strong> occurred.</p>
  
  <p>I tried to change Issuer to https address and used customized DiscoveryDocumentRequest. But it was not work.</p>
  
  <p>When I remove the nginx and access <a href="http://10.2.5.90:8000" rel="nofollow noreferrer">http://10.2.5.90:8000</a>, It worked well.</p>
  
  <p>IdentityServer:Startup.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>public void ConfigureServices(IServiceCollection services)
  {
      // ...other codes
      var builder = services.AddIdentityServer(options =&gt;
      {
          options.Events.RaiseErrorEvents = true;
          options.Events.RaiseInformationEvents = true;
          options.Events.RaiseFailureEvents = true;
          options.Events.RaiseSuccessEvents = true;
  
          options.IssuerUri = "https://10.2.5.90:8888";
      });
      // ...other codes
  }
  
  </code></pre>
  
  <p>Client: Program.cs</p>
  
  <pre class="lang-cs prettyprint-override"><code>private static async Task&lt;string&gt; GetAccessTokenAsync()
  {
      var client = new HttpClient();
      var req = new DiscoveryDocumentRequest
      {
          Address = "https://10.2.5.90:8888",
          Policy = new DiscoveryPolicy
          {
              ValidateIssuerName = false,
              ValidateEndpoints = false,
          }
      };
      var disco = await client.GetDiscoveryDocumentAsync(req);
      if (disco.IsError)
      {
          Console.WriteLine(disco.Error);
          // output: Error connecting to http://localhost:8000/.well-known/openid-configuration/jwks. Object reference not set to an instance of an object..
          return null;
      }
  
      // ...other codes
  }
  
  
  </code></pre>
  
  <h3>Edit:</h3>
  
  <p>I changed the code when config identity server and it works when running discovery. </p>
  
  <pre class="lang-cs prettyprint-override"><code>var builder = services.AddIdentityServer(options =&gt;
  {
      options.PublicOrigin = "https://10.2.5.90:8888";
  });
  </code></pre>
  
  <p>However, I still couldn't access my api. The error is <strong>Exception occurred while processing message.IDX20803: Unable to obtain configuration from: '<a href="http://localhost:8000/.well-known/openid-configuration" rel="nofollow noreferrer">http://localhost:8000/.well-known/openid-configuration</a>'</strong> and I'm researchig the solution</p>