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.24k stars 639 forks source link

Cannot set public_url when run via Docker #477

Open johnzimm opened 4 years ago

johnzimm commented 4 years ago

I've seen other issues with trying to use the public_url switch but I don't really see any of them definitively resolved.

I am trying to run tileserver-gl with the following command:

docker run --rm -it -p 8080:80 maptiler/tileserver-gl:latest --public_url /tiles

The tileserver-gl runs and I can access it at http://servername:8080/

By passing the --public_url parameter I expected to be accessing it at http://servername:8080/tiles instead.

My intent here is to proxy this upstream behind Apache HTTPD so that I can access tileserver-gl at https://example.com/tiles

After passing the --public_url in the page renders same as before and everywhere I expected /tiles to be rendered in the source, replacing {{public_url}} in the template it is just simply left blank as if nothing was passed in.

Is anyone successfully running this via docker (or otherwise) using the --public_url option?

fabiuk commented 4 years ago

Hi, I also struggled with that issue once. Try to pass the full URL for the --publicurl parameter, i.e.: --public_url http://servername:8080/tiles_

BR

afruzan commented 2 years ago

I have the same issue... any solution?

afruzan commented 2 years ago

I recommend supporting x-forwarded-host same as host header in tileserver-gl as a solution for when a proxy is used.

afruzan commented 2 years ago

but because we use something like https://example.com/tiles in production and /tiles part of the url does not pass by x-forward headers I used x-map-root-url custom header that can be passed by reverse proxy by a simple config.

by this, publicUrl is not fixed. in my case I cannot set --public-url arg at startup even it's problem be fixed.

another and may be better workaround is having a custom header like tileserver-public-url, to be able to pass it for each request.

scara commented 2 years ago

HI @guidomocha,

Try to pass the full URL for the --public_url parameter, i.e.: --public_url http://servername:8080/tiles

Did you try to set it as the Absolute Base URL according with how do you expect external consumers to access the service through your reverse proxy via your own settings? I.e. http(s)://reverse-proxy-fqdn/path/to/tileserver.

HTH, Matteo

afruzan commented 2 years ago

@scara Hi, Thank your for your attention to my posts.

In my case, end users may access front-end app with different host addresses (IPs). My backend API uses a reverse-proxy in order to proxy all requests started with /map to the tileserver.

Although I have a list of that host addresses (IPs) in backend API, but they cannot be used as --public_url parameter, because the --public_url parameter must pass at startup of tileserver and in my case tileserver is not started and managed by backend API directly.

so I searched for a a way to passing the public_url at each request or creating it at tileserver dynamically.