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

Cannot set public_url when run via Docker

Open johnzimm opened this issue 4 years ago • 6 comments

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?

johnzimm avatar Sep 23 '20 04:09 johnzimm

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

BR

fabiuk avatar Sep 23 '20 06:09 fabiuk

I have the same issue... any solution?

afruzan avatar Jan 22 '22 17:01 afruzan

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

afruzan avatar Jan 22 '22 17:01 afruzan

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.

afruzan avatar Jan 22 '22 18:01 afruzan

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

scara avatar Jan 23 '22 13:01 scara

@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.

afruzan avatar Jan 26 '22 14:01 afruzan