docker icon indicating copy to clipboard operation
docker copied to clipboard

Backend Nginx Configuration Issue with Port/Protocol Loss in Redirects

Open azafree opened this issue 1 month ago • 2 comments

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;
}

azafree avatar Oct 31 '25 00:10 azafree