Skip to main content

Deploying behind a reverse proxy

When a Lagoon application is deployed behind a reverse proxy or a gateway, HTTP header forwarding must be enabled.

Enabling HTTP header forwarding​

Add the following configuration to appsettings.json:

{
"Lagoon": {
"UseForwardedHeaders": true
}
}

The UseForwardedHeaders middleware is automatically added by Lagoon with the ForwardedHeaders.All option.

For more information, see the Microsoft documentation:

The OnConfigureForwardedHeaders method lets you customize header forwarding.

"OpenID Connect request cannot be retrieved" error​

If GET /connect/authorize returns the The OpenID Connect request cannot be retrieved exception, it is probably because the HTTP request's host name does not match the PublicUrl defined in appsettings.json.

Check that:

  • the URL set as PublicUrl is correct;
  • the UseForwardedHeaders option is set to true in the configuration file.

Azure Application Gateway​

Azure Application Gateway does not send the X-Forwarded-Host header, but the X-Original-Host header instead.

The application configuration must be updated by adding the following method to the Main.cs file of the Server project:

///<inheritdoc/>
protected override void OnConfigureForwardedHeaders(ForwardedHeadersOptions options)
{
base.OnConfigureForwardedHeaders(options);
options.ForwardedHostHeaderName = "X-Original-Host";
}
Note

For more flexibility, the value can be read from the configuration.