julien-nc / gpxpod

Nextcloud app to view gpx track files
GNU Affero General Public License v3.0
40 stars 3 forks source link

Selfhosted Tile Server #51

Open markuman opened 3 months ago

markuman commented 3 months ago

I've completed a very very simple tile server for selfhosting that works also with GpxPod.
The planet.mbtiles file is ~85GB. So no API Key is necessary anymore.
Maybe someone is interested: https://github.com/markuman/sms

mkdir osm
wget -O osm/planet.mbtiles https://hidrive.ionos.com/api/sharelink/download?id=SYEgScrRe
podman run -ti --rm -p 9000:9000 --name sms -v $(pwd)/osm/:/data/ registry.gitlab.com/markuman/sms:latest
firefox http://localhost:9000

nextcloud GpxPod

  1. Deploy the container/service behind a webproxy (caddy, nginx, traefik,...you name it.) to get a valid SSL certificate.
  2. Goto GpxPod Settings -> Tile Servers
    • Type: Vector
    • Server address: https://<YOUR_SMS_SERVICE_DEPLOYMENT>/v1/styles/osm-bright-gl-style@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0
select * from oc_gpxpod_tileservers;
 id | user_id | type |           name            |                                                        url                                                         | min_zoom | max_zoom | attribution 
----+---------+------+---------------------------+--------------------------------------------------------------------------------------------------------------------+----------+----------+-------------
  5 | markuman       |    1 | maps.osuv.de              | https://maps.osuv.de/v1/styles/osm-bright-gl-style@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0       |          |          |  
  6 | markuman       |    1 | maptiler-basic-gl-style   | https://maps.osuv.de/v1/styles/maptiler-basic-gl-style@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0   |          |          |  
  7 | markuman       |    1 | maptiler-terrain-gl-style | https://maps.osuv.de/v1/styles/maptiler-terrain-gl-style@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0 |          |          |  
 12 | markuman       |    1 | positron-gl-style         | https://maps.osuv.de/v1/styles/positron-gl-style@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0         |          |          |  
 13 | markuman       |    1 | liberty                   | https://maps.osuv.de/v1/styles/osm-liberty@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0               |          |          |  
(5 rows)

grafik

julien-nc commented 3 months ago

Wow awesome! Thanks for mentioning this here.

Keep in mind this can only work if all the data endpoints (in style.json) are on the same domain as the style.json address. GpxPod authorizes the domain of the vector tile server in the page CSP.

markuman commented 3 months ago

Keep in mind this can only work if all the data endpoints (in style.json) are on the same domain as the style.json address. GpxPod authorizes the domain of the vector tile server in the page CSP.

Yes, they are. This is the outpuf of https://maps.osuv.de/v1/styles/osm-bright-gl-style@1.0.0/style.json?fonts=fonts-gl@1.0.0&tiles=mytiles@1.0.0 for example.
And all paths are relativ https://github.com/markuman/sms/blob/latest/simple_mbtiles_server/vendor/index.html#L18
So it should work on any domain.

I host home, that's the reason why there is a basic auth infront of my maps service - when accessing it from the internet.
Inside my local network, there is no basic auth.

in caddy

        @not-local not remote_ip 192.168.178.0/24
        basic_auth @not-local {

but this is out of scope. I just want to clearify why my tile server isn't public available.

And I paid the ionos hidrive to distribute the large mbtiles file for others.
I hope the hurdle has never been smaller to host the map of the entire world from zoom level 0 to 20 :smile: