Skip to content

[Feature] Support for X-Forwarded-Port in AKS Application Routing Add-on #4977

@torumakabe

Description

@torumakabe

Certain applications such as Spring Boot, when running behind a gateway require the HTTP header X-Forwarded-Port. However, the current AKS Application Routing Add-on does not appear to set X-Forwarded-Port.

Below is the result of running httpbin, which returns the request’s HTTP headers behind the Application Routing Add-on. The X-Forwarded-Port header is not set.

The IP addresses in the text have been replaced with dummy ones.

curl http://203.0.113.1/headers
{
  "headers": {
    "Accept": "*/*", 
    "Host": "203.0.113.1", 
    "User-Agent": "curl/8.7.1", 
    "X-Forwarded-Host": "203.0.113.1", 
    "X-Forwarded-Scheme": "http", 
    "X-Scheme": "http"
  }
}

So I tried configuring it with a snippet of ingress. I also applied the following annotations to test whether custom headers can be used or variables can be read.

  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-Forwarded-Port "80";
      proxy_set_header X-Test-Pass-Port $pass_port;
      proxy_set_header X-Test-Server-Port $server_port;
      proxy_set_header X-Test-Service-Port $service_port;

However, it seems that X-Forwarded-Port is treated specially and isn’t being set.

curl http://203.0.113.1/headers
{
  "headers": {
    "Accept": "*/*", 
    "Host": "203.0.113.1", 
    "User-Agent": "curl/8.7.1", 
    "X-Forwarded-Host": "203.0.113.1", 
    "X-Forwarded-Scheme": "http", 
    "X-Scheme": "http", 
    "X-Test-Pass-Port": "8080", 
    "X-Test-Server-Port": "8080", 
    "X-Test-Service-Port": "80"
  }
}

The documentation’s list of limitations does not explicitly mention X-Forwarded-Port.

I would appreciate it if you could ensure this header is set for applications that require X-Forwarded-Port. You don’t need to configure it by default, support via an Ingress configuration snippet is sufficient. Thanks!

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions