Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use HTTP_X_FORWARDED_PROTO when behind a proxy #1637

Closed
wants to merge 1 commit into from

Conversation

blink38
Copy link

@blink38 blink38 commented Mar 24, 2022

When behind a proxy, absolute root url is construct using HTTP_X_FORWARDED_HOST but is ignoring the scheme.

The modification proposed is to use HTTP_X_FORWARDED_PROTO which include the scheme when construct the absolute root url.

Use case :
Piwigo is running in docker container which expose the service with HTTP. A traefik proxy is exposing the service via HTTPs. Without this modification, url are return with http:// scheme.

May resolve issue #1527

@gasparakos
Copy link

It is working for Us!

Our system runs in docker, behind an apache reverse proxy. Container port 80 is exposed on 12380. On apache RequestHeader set X-Forwarded-Proto 'https' was set but some functionality didn't worked, eg: file upload or mobile client show only white square insted of pictures. After apply 4eb8765 problems was resolved.

Thank You!

@mossroy
Copy link

mossroy commented Jun 26, 2022

For information, I had created an almost identical PR 6 years ago: #483 (that was not merged either, unfortunately)

To me, this is still relevant, and I still workaround it with the following code in local/config/config.inc.php:

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
       $_SERVER['HTTPS']='on';
}

@plegall
Copy link
Member

plegall commented Jul 21, 2022

I close this pull-request, as a duplicate of #483

@plegall plegall closed this Jul 21, 2022
@blink38
Copy link
Author

blink38 commented Jul 22, 2022

The proposed code by @mossroy #1637 (comment) is a workaround, waiting for the MR (#483 or #1637) to be accepted.

It's not relevant to say : the solution is to put the fix code in the config.php instead of correcting the code where it must be done.

@codeceptsDE codeceptsDE mentioned this pull request Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants