calls made in http while browsing on https #984

Closed
opened 2026-10-05 00:26:37 +02:00 by adam · 5 comments
Owner

I am using https on my gallery and when I want to generate multiple size images, the batch manager call i.php via http and this request gets blocked. The blocked request shows in the dev console of a browser (Opera, did not show up in Firefox). As a result the thumbnails generation fails with an error "8 photos can not be regenerated".

This issue got discovered by flop25 in this topic https://piwigo.org/forum/viewtopic.php?pid=175220#p175220

I am using https on my gallery and when I want to generate multiple size images, the batch manager call i.php via http and this request gets blocked. The blocked request shows in the dev console of a browser (Opera, did not show up in Firefox). As a result the thumbnails generation fails with an error "8 photos can not be regenerated". This issue got discovered by flop25 in this topic https://piwigo.org/forum/viewtopic.php?pid=175220#p175220 <!-- github-sync-id:530802677 -->
adam closed this issue 2026-10-05 00:26:37 +02:00
Author
Owner

I can reproduce this exact problem and have figured out a hack to fix it. This occurs for me because I use piwigo with HTTP, but I have it behind a reverse proxy which handles SSL/TLS termination for external traffic.

Because the logic in Piwigo at ws.php?format=json&method=pwg.getMissingDerivatives returns absolute URLs, and because Piwigo thinks it's using HTTP, the protocol is returned to my browser as HTTP but really it's HTTPS.

The fix I did for my instance is to modify gallery/include/functions_url.inc.php
line 48 http should be change to https, because of reverse proxy external protocol being HTTPS.

The long term fix will need to be made in this file, but I'm not a PHP programmer so I can't really contribute more to this.

I can reproduce this exact problem and have figured out a hack to fix it. This occurs for me because I use piwigo with HTTP, but I have it behind a reverse proxy which handles SSL/TLS termination for external traffic. Because the logic in Piwigo at ws.php?format=json&method=pwg.getMissingDerivatives returns absolute URLs, and because Piwigo thinks it's using HTTP, the protocol is returned to my browser as HTTP but really it's HTTPS. The fix I did for my instance is to modify gallery/include/functions_url.inc.php line 48 http should be change to https, because of reverse proxy external protocol being HTTPS. The long term fix will need to be made in this file, but I'm not a PHP programmer so I can't really contribute more to this. <!-- github-comment-id:619600549 -->
Author
Owner

Oh shoot, I didn't see choenig's mention there. Whoops. I'm new to this jithub

Oh shoot, I didn't see choenig's mention there. Whoops. I'm new to this jithub <!-- github-comment-id:619600769 -->
Author
Owner

in case of header X-Forwarded-Host is set, function get_absolute_root_url will not take care of ports.
see https://github.com/Piwigo/Piwigo/blob/86c561156203870b2c07ad9e4a954098c1d69cc2/include/functions_url.inc.php#L50

e.g. for nginx just add to your proxy location:
proxy_set_header X-Forwarded-Host $http_host;

see also #681, #982

in case of header X-Forwarded-Host is set, function get_absolute_root_url will not take care of ports. see https://github.com/Piwigo/Piwigo/blob/86c561156203870b2c07ad9e4a954098c1d69cc2/include/functions_url.inc.php#L50 e.g. for nginx just add to your proxy location: `proxy_set_header X-Forwarded-Host $http_host;` see also #681, #982 <!-- github-comment-id:774499529 -->
Author
Owner

@hoedlmoser
thank you, this was exactly the solution i needed for piwigo docker container (image from linuxserver.io) with a haproxy reverse proxy in front where ssl terminates, just set the X-Forwarded-Host Header and no more connections over https on port 80

i set the following Headers in my Backend

http-request set-header X-Forwarded-Proto https
http-request set-header X-Forwarded-Host photos.example.com

@hoedlmoser thank you, this was exactly the solution i needed for piwigo docker container (image from linuxserver.io) with a haproxy reverse proxy in front where ssl terminates, just set the X-Forwarded-Host Header and no more connections over https on port 80 i set the following Headers in my Backend `http-request set-header X-Forwarded-Proto https` `http-request set-header X-Forwarded-Host photos.example.com` <!-- github-comment-id:1339349360 -->
Author
Owner

Thanks, that did the trick for me too!

Thanks, that did the trick for me too! <!-- github-comment-id:1365247369 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#984