Announcement

#1 2012-05-01 12:00:17

robin13
Member
Munich, Germany
2012-05-01
2

Piwigo forwards to wrong port when used behind reverse proxy

My webserver configuration is:

Internet -> Varnish (piwig.mydomain.com:80) -> Lighttpd (localhost:8081)

i.e. connections from the internet first hit the reverse proxy (Varnish) on port 80, and are then forwarded to the lighttpd webserver backend running on port 8081.

For the most part (browsing images, uploading images), it works fine, but some links (e.g. "Home") direct to the correct domain (piwig.mydomain.com), but the internal port (8081), which is not (and should not be) accessible from the internet.

I have looked in the piwig_config table in the database, and grepped the piwig installation directory, but can't find anywhere to set the site url without the internal port number.

Is there any way to use pwigo behind a reverse proxy like this?

Offline

 

#2 2012-05-01 12:38:50

robin13
Member
Munich, Germany
2012-05-01
2

Re: Piwigo forwards to wrong port when used behind reverse proxy

Here is my piwigo installation for you to see/test:
http://piwigo.robinclarke.net/

Offline

 

#3 2012-05-01 21:29:59

rvelices
Piwigo Team
2005-12-29
1960

Re: Piwigo forwards to wrong port when used behind reverse proxy

I believe that you have to manually modify in file include/functions_url.inc.php, function get_absolute_root_url, the part with SERVER_PORT ...

Offline

 

#4 2015-10-12 03:39:59

ewmalmbe
Guest

Re: Piwigo forwards to wrong port when used behind reverse proxy

I've been trying to do the same with my squid instance and I stumbled over this little gem!

http://squid-web-proxy-cache.1019090.n4 … 13221.html

The suggestion is to add "vport=80" to the http_port line.

Worked like a charm!!

 

#5 2017-02-10 09:54:23

samih
Member
2017-02-10
3

Re: Piwigo forwards to wrong port when used behind reverse proxy

I had the same problem with my hosting provider.

The site was served via https, but Piwigo kept on redirecting to https://example.com:80/...
Which broke for example sitemaps and SSI functions.

Of course i was not allowed to change server configuration, so i made locally a quick and (very) dirty fix to the SERVER_PORT -section of functions_url.inc.php so that it never appends the port number to the URL.

I think that there should be an configuration variable for this...

Offline

 

#6 2017-02-10 17:12:27

croucrou
Member
2014-10-13
9

Re: Piwigo forwards to wrong port when used behind reverse proxy

I think I hav the same problem with @samih

I am with Piwigo 2.8.6 installed on share hosting.

I am also wondering why secured links created by piwigo all contains :80 that makes them not functional.

I noticed it the OpenStreetMap plugin : on map view, I can't see the thumbnail and the link to the picture is not working.
Indeed instead of :
https://www.mondomaine.com/photos/pictu … 4/category
the plugin send to
https://www.mondomaine.com:80/photos/pi … 4/category (adding the :80 to the URL)
I open an issue for that on [Github] piwigo-openstreetmap issue #106 without success

Then I found the same situation with the notification Email :  in the mail I receive, thumbnail and link to the album are broken for the exact same reason.

And finally with the html upload (in the administration section), when picture are uploaded and I arrived in the summary of uploaded pictures, I see the broken thumbnail for again the same reason.

I tried to des-activate "Force HTTPS" plugin or config in "local FileEditor" plugin without any success.

I don't face this situation with other programs such as NextCloud, PrivateBin, etc. hosted on the same place so I guess the problem comes from Piwigo.

Where I should look for ?

Samih, could please explain what you modified in order to solve your problem ?

Thanks in advance !

Offline

 

#7 2017-02-10 20:37:22

samih
Member
2017-02-10
3

Re: Piwigo forwards to wrong port when used behind reverse proxy

@croucrou

First of all, if trying this method, make backup of at least your original functions_url.inc.php.

What i did, was i commented out the part of function which does the port finding routine, resulting in following lines in functions_url.inc.php file (lines 70-81):

Code:

     {
      $url .= $_SERVER['HTTP_HOST']; 
//      if ( (!$is_https && $_SERVER['SERVER_PORT'] != 80)
//            ||($is_https && $_SERVER['SERVER_PORT'] != 443))
//      {
//        $url_port = ':'.$_SERVER['SERVER_PORT'];
//        if (strrchr($url, ':') != $url_port)
//        {
//          $url .= $url_port;
//        }
//      }
    }

Use your favourite text editor to comment out lines with two slashes in the beginning of each line as in code sample above. If something breaks revert to backed up file. I'm not a coder so this is not very elegant solution but it worked for me. Maybe we should make a feature request of this, if there is more need for such modification. :)

Offline

 

#8 2017-02-10 23:03:51

croucrou
Member
2014-10-13
9

Re: Piwigo forwards to wrong port when used behind reverse proxy

Yeeeeeees !

Thanks so much Samih !
It has been quite a long time I am trying to find a solution to these broken &#[@*µ$ URLs !

Your solution is working indeed, I am really happy.

Thanks again !

Crou²

Offline

 

Board footer

Powered by FluxBB

github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2019 · Contact