Appending the port to the URI in links breaks reverse proxy #1635

Closed
opened 2026-10-05 00:50:57 +02:00 by adam · 2 comments
Owner

Hello, I recently setup piwigo on my server, in a docker container, which runs behind a reverse-proxy that automatically manages Let's Encrypt SSL certificates and endpoints. This allows me to connect to Piwigo (and other dockerized web apps) with https, without the need to configure the web apps themselves for https. I'm using the Modus theme, and updated to the latest versions of the app & plugins installed.

Sometimes, I click a link in the app and I get an "unable to connect" error, then notice that the URL it's trying to connect to has the port appended to it, like so: https://my-piwigo.example.com:80/the/path. From the "perspective" of the (internal) app the port number is 80, but from the client side (external, my web browser) it should be 443. The login button, as accessed through the "Login" link in the upper-right corner of an album, is one example of this. I enter my credentials, click Submit, and get a browser error:

This site can’t provide a secure connection my-piwigo.example.com sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

The URL in the location bar has an :80 on the end.

If you just leave the port number off, it would work fine. Perhaps this "feature" was added to support installations that run on non-standard ports? If so, is there somewhere I can try setting it to 443? Although, since port 80 is the correct "internal" (behind the proxy) port, that might also not work, depending how the app works.

Hello, I recently setup piwigo on my server, in a docker container, which runs behind a [reverse-proxy](https://hub.docker.com/r/jwilder/nginx-proxy) that automatically manages Let's Encrypt SSL certificates and endpoints. This allows me to connect to Piwigo (and other dockerized web apps) with https, without the need to configure the web apps themselves for https. I'm using the *Modus* theme, and updated to the latest versions of the app & plugins installed. Sometimes, I click a link in the app and I get an "unable to connect" error, then notice that the URL it's trying to connect to has the port appended to it, like so: https://my-piwigo.example.com:80/the/path. From the "perspective" of the (internal) app the port number is 80, but from the client side (external, my web browser) it should be 443. The login button, as accessed through the "Login" link in the upper-right corner of an album, is one example of this. I enter my credentials, click Submit, and get a browser error: ``` This site can’t provide a secure connection my-piwigo.example.com sent an invalid response. ERR_SSL_PROTOCOL_ERROR ``` The URL in the location bar has an `:80` on the end. If you just leave the port number off, it would work fine. Perhaps this "feature" was added to support installations that run on non-standard ports? If so, is there somewhere I can try setting it to 443? Although, since port 80 is the correct "internal" (behind the proxy) port, that might also not work, depending how the app works. <!-- github-sync-id:1599791620 -->
adam closed this issue 2026-10-05 00:50:57 +02:00
Author
Owner

Hi, I seem to have encountered a similar problem. I am also using nginx to reverse proxy my piwigo.
Here are the settings I added using LocalFiles Editor:

// Support X-Forwarded-Proto header for HTTPS detection in PHP
// Also need to set port correctly
if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
    $_SERVER['HTTPS'] = 'on';
    //$_SERVER['SERVER_PORT'] = '443';
}

Here is my nginx configuration file:

server {
        listen 443 ssl;
        server_name example.com;
        ssl_certificate xxx/fullchain.pem;
        ssl_certificate_key xxx/privkey.pem;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        client_max_body_size 10G;

   location / {
        proxy_pass http://192.168.0.63;

        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-NginX-Proxy true;

        proxy_set_header        X-Forwarded-Host $http_host;
        proxy_set_header        X-Forwarded-Proto https;
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection "upgrade";
    }
}

You can try to see which settings are useful to you.

Hi, I seem to have encountered a similar problem. I am also using nginx to reverse proxy my piwigo. Here are the settings I added using LocalFiles Editor: ``` // Support X-Forwarded-Proto header for HTTPS detection in PHP // Also need to set port correctly if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) { $_SERVER['HTTPS'] = 'on'; //$_SERVER['SERVER_PORT'] = '443'; } ``` Here is my nginx configuration file: ``` server { listen 443 ssl; server_name example.com; ssl_certificate xxx/fullchain.pem; ssl_certificate_key xxx/privkey.pem; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; client_max_body_size 10G; location / { proxy_pass http://192.168.0.63; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Proto https; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } ``` You can try to see which settings are useful to you. <!-- github-comment-id:1456949036 -->
Author
Owner

Thanks! I'm going to close this issue. I'm not sure what I did, but this stopped being a problem for me at some point.

Thanks! I'm going to close this issue. I'm not sure what I did, but this stopped being a problem for me at some point. <!-- github-comment-id:1457016759 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#1635