I have the following configuration: browser ->(https)-> apache reverse proxy ->(http)-> nginx reverse proxy ->(http)-> piwigo
In this case, the variable $_SERVER['HTTP_X_FORWARDED_HOST'] on Piwigo does not hold the hostname currently expected in Piwigo code (see https://github.com/Piwigo/Piwigo/blob/master/include/functions_url.inc.php#L52), but a comma-separated list of hostnames. In my case it was twice the right one: myhostname, myhostname
The result was a broken batch resize feature, because the API returned invalid URLs like: https://myhostname, myhostname/i.php?...
where it should be: https://myhostname/i.php?...
I managed to workaround that by adding the following lines in local/config/config.inc.php. When there is a comma in this variable, it keeps only the first value (the one before the first comma):
I have the following configuration:
`browser ->(https)-> apache reverse proxy ->(http)-> nginx reverse proxy ->(http)-> piwigo`
In this case, the variable `$_SERVER['HTTP_X_FORWARDED_HOST']` on Piwigo does not hold the hostname currently expected in Piwigo code (see https://github.com/Piwigo/Piwigo/blob/master/include/functions_url.inc.php#L52), but a comma-separated list of hostnames. In my case it was twice the right one: `myhostname, myhostname`
The result was a broken batch resize feature, because the API returned invalid URLs like:
`https://myhostname, myhostname/i.php?...`
where it should be:
`https://myhostname/i.php?...`
I managed to workaround that by adding the following lines in `local/config/config.inc.php`. When there is a comma in this variable, it keeps only the first value (the one before the first comma):
```
if ($_SERVER['HTTP_X_FORWARDED_HOST'] && strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ',') !== FALSE){
$_SERVER['HTTP_X_FORWARDED_HOST'] = explode(',',$_SERVER['HTTP_X_FORWARDED_HOST'])[0];
}
```
I think that this logic should be in https://github.com/Piwigo/Piwigo/blob/master/include/functions_url.inc.php#L52
That's how some other projects implemented it. See https://github.com/xp-framework/xp-framework/issues/162 , https://github.com/RicoSuter/NSwag/issues/2370 , https://github.com/pallets/werkzeug/issues/371 or https://bz.apache.org/bugzilla/show_bug.cgi?id=57665#c14
I can create a PR if you want.
<!-- github-sync-id:1284963928 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
I have the following configuration:
browser ->(https)-> apache reverse proxy ->(http)-> nginx reverse proxy ->(http)-> piwigoIn this case, the variable
$_SERVER['HTTP_X_FORWARDED_HOST']on Piwigo does not hold the hostname currently expected in Piwigo code (see https://github.com/Piwigo/Piwigo/blob/master/include/functions_url.inc.php#L52), but a comma-separated list of hostnames. In my case it was twice the right one:myhostname, myhostnameThe result was a broken batch resize feature, because the API returned invalid URLs like:
https://myhostname, myhostname/i.php?...where it should be:
https://myhostname/i.php?...I managed to workaround that by adding the following lines in
local/config/config.inc.php. When there is a comma in this variable, it keeps only the first value (the one before the first comma):I think that this logic should be in https://github.com/Piwigo/Piwigo/blob/master/include/functions_url.inc.php#L52
That's how some other projects implemented it. See https://github.com/xp-framework/xp-framework/issues/162 , https://github.com/RicoSuter/NSwag/issues/2370 , https://github.com/pallets/werkzeug/issues/371 or https://bz.apache.org/bugzilla/show_bug.cgi?id=57665#c14
I can create a PR if you want.