tileserver-gl
tileserver-gl copied to clipboard
X-Forwarded-Host Not Used in URLs
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
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
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 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
@BuddhiAbeyratne, I didn't try the path proposed by @jasonpepper but found a trick : add the "baseURL" in your options (config file).
@mcm-jyl Are you certain the baseURL
works? See my https://github.com/maptiler/tileserver-gl/issues/294#issuecomment-729875858