Skip to content

Pass original port in all proxied queries #479

Description

@rayrapetyan

Feature request

Feature description

Currently in a reverse proxy generated section proxied port looks as below:

proxy_set_header X-Forwarded-Port  $server_port;

$server_port is the port nginx is listening on, which is not always the same port UA connects to (e.g. when nginx is listening inside a docker container on port 80, but UA connects to localhost:8080).
IMO we should pass here the original port UA connects to, e.g. for http://localhost:8080 X-Forwarded-Port should be 8080. For this, a solution from https://stackoverflow.com/a/63366106/1017293 can be used, e.g. we need to add:

map $http_host $orig_port {
    default $scheme;
    "~^[^\:]+:(?<p>\d+)$" $p;
}

into http section of the nginx.conf and then in the proxy.conf use:

proxy_set_header X-Forwarded-Port  $orig_port;

How the feature is useful

Most of OAuth providers and any other server-side redirect solutions will work as expected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions