Skip to content

Configure forwarded headers middleware - #65

Open
gunndabad with Copilot wants to merge 3 commits into
mainfrom
enable-forwarded-headers
Open

gunndabad with Copilot wants to merge 3 commits into
mainfrom
enable-forwarded-headers

Conversation

Copilot AI commented Nov 11, 2026 •

Copy link
Copy Markdown

Configures the forwarded headers middleware in Program.cs so ASP.NET Core honours the X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host headers from the hosting proxy. This means the app sees the correct client IP, request host and scheme, so HttpContext.Request.IsHttps is true for HTTPS requests. For example, generated absolute URLs and redirects use the public host, and secure cookies work as expected.

This uses explicit configuration rather than the ASPNETCORE_FORWARDEDHEADERS_ENABLED environment variable:

  • ForwardedHeaders.All is processed.
  • KnownIPNetworks and KnownProxies are cleared, since the proxy's address within the cluster isn't known ahead of time.
  • UseForwardedHeaders() runs first in the pipeline.

Closes #40

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace the ASPNETCORE_FORWARDEDHEADERS_ENABLED environment variable in
the Docker image with explicit forwarded headers configuration.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gunndabad gunndabad changed the title Set ASPNETCORE_FORWARDEDHEADERS_ENABLED in Docker image Configure forwarded headers middleware Nov 11, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forwarded headers middleware

2 participants