Skip to content

Backend Nginx Configuration Issue with Port/Protocol Loss in Redirects #2493

@azafree

Description

@azafree

The frontend uses Nginx as a reverse proxy with HTTPS enabled, but it utilizes a non-standard web port (e.g., port 8443). After the frontend Nginx reverse proxy, the backend Nginx uses an HTTP connection on port 80. As a result, redirects from the backend lose the original port and protocol.
It is recommended to add absolute_redirect off; to the configuration file at .examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf.

This Nginx location configuration for reverse proxy:
location / {
proxy_pass http://127.0.0.1:80$request_uri;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header Early-Data $ssl_early_data;

    # Websocket
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs infoAdditional info needed to triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions