sebsauvage/Shaarli — pull request #209 by Httqm (2014-10-21 14:04:33+00:00)
Title: Skip webserver port detection if running behind a reverse proxy

When running Shaarli behind a reverse proxy, Ajax-based functions (such as autocomplete of shaarlink tags) stops working.
- BEFORE installing the reverse proxy : the webserver is accessible from the Internet directly on port 80. This port is also detected by the "serverUrl" function. Ajax requests are sent there for autocomplete of tags : http://shaarli.domain.tld/?ws=tags&term=
- AFTER installing the reverse proxy : the webserver is listening on port 8080 (or any other port : this is some webserver-internal stuff), and it's listening to the reverse proxy exclusively. The reverse proxy itself is listening on port 80. It such case, the "serverUrl" function detects "8080" as the server port, and Ajax queries are sent to http://shaarli.domain.tld:8080/?ws=tags&term= , where nobody's publicly listening. Then no more autocompletes :-(

The change I've made tries to circumvent this : if no reverse proxy port is declared, let's keep the previous behaviour (autodetect the server port). Otherwise, use the provided reverse proxy port (mostly 80) to build the destination addresses :

http://shaarli.domain.tld:/?ws=tags&term=