tileserver-gl icon indicating copy to clipboard operation
tileserver-gl copied to clipboard

X-Forwarded-Host Not Used in URLs

Open jasonpepper opened this issue 8 years ago • 5 comments

I set up a tileserver-gl-light instance behind an IIS reverse proxy using IIS Rewrite. I set the X-Forwarded-Host request header appropriately. However, the URLs that are returned in my styles do not have the hostname from the X-Forwarded-Host header. The URLs have the hostname from the Host header.

The documentation for the express library says to use req.hostname, but tileserver-gl is using req.headers.host.

https://expressjs.com/en/guide/behind-proxies.html

jasonpepper avatar Feb 10 '17 15:02 jasonpepper

A workaround for this in IIS is to force IIS to not change the Host header.

\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost

jasonpepper avatar Feb 10 '17 16:02 jasonpepper

im facing the same issue with nginx did you find a solution i tried adding the a domain via the config file no luck there ether

BuddhiAbeyratne avatar Feb 13 '17 06:02 BuddhiAbeyratne

@BuddhiAbeyratne What you need to do is find a way to get the Host header to contain the hostname that you want the client to make its style/glyph/sprite requests from. I did a quick Google search "nginx preserve host header" and the following post came up, which may be helpful for you:

http://serverfault.com/questions/598202/make-nginx-to-pass-hostname-of-the-upstream-when-reverseproxying

jasonpepper avatar Feb 13 '17 14:02 jasonpepper

@BuddhiAbeyratne, I didn't try the path proposed by @jasonpepper but found a trick : add the "baseURL" in your options (config file).

mcm-jyl avatar Jul 05 '18 15:07 mcm-jyl

@mcm-jyl Are you certain the baseURL works? See my https://github.com/maptiler/tileserver-gl/issues/294#issuecomment-729875858

mloskot avatar Nov 18 '20 18:11 mloskot