maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.17k stars 630 forks source link

X-Forwarded-Host Not Used in URLs #119

Open jasonpepper opened 7 years ago

jasonpepper commented 7 years ago

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 commented 7 years ago

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

BuddhiAbeyratne commented 7 years ago

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

jasonpepper commented 7 years ago

@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

mcm-jyl commented 6 years ago

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

mloskot commented 3 years ago

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