VOOZH about

URL: https://wiki.archlinux.org/title/Tegola

⇱ Tegola - ArchWiki


Jump to content
From ArchWiki


Tegola is a vector tile server for serving Mapbox Vector Tiles. It can be used to publish vector tiles from data sources such as PostGIS.

Installation

Install the package tegola-headlessAUR.

Note The tegola-headlessAUR package does not include the built-in Tegola web viewer. It is intended for server deployments where Tegola is used as a backend vector tile service.

Configuration

The main configuration file is:

/etc/tegola/tegola.toml

The file is installed with restricted permissions because it may contain database connection strings and passwords:

$ sudo ls -ld /etc/tegola /etc/tegola/tegola.toml
drwxr-x--- root tegola /etc/tegola
-rw-r----- root tegola /etc/tegola/tegola.toml

The service runs as the tegola user.

A minimal configuration may look like this:

/etc/tegola/tegola.toml
[webserver]
port = ":8080"

See the upstream documentation for provider and map configuration examples.

PostGIS provider

Tegola can serve vector tiles from PostGIS. A minimal provider and map configuration looks like this:

/etc/tegola/tegola.toml
[webserver]
port = ":8080"

[[providers]]
name = "postgis"
type = "mvt_postgis"
uri = "postgres://user:password@localhost:5432/database?sslmode=disable"

[[providers.layers]]
name = "example"
geometry_fieldname = "geom"
geometry_type = "Polygon"
id_fieldname = "id"
srid = 3857
sql = """
SELECT
id,
ST_AsMVTGeom(geom, !BBOX!) AS geom
FROM public.example
WHERE geom && !BBOX!
"""

[[maps]]
name = "example"

[[maps.layers]]
provider_layer = "postgis.example"
min_zoom = 0
max_zoom = 14

After changing the configuration, restart the service:

# systemctl restart tegola.service

Usage

Start and enable tegola.service.

Tegola listens on port 8080 by default. Test the local HTTP endpoint with:

$ curl -I http://127.0.0.1:8080/

Reverse proxy

Tegola is commonly deployed behind a reverse proxy such as nginx.

Example nginx location:

/etc/nginx/nginx.conf
location /tegola/ {
proxy_pass http://127.0.0.1:8080/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

After changing the nginx configuration, test the configuration file:

# nginx -t

Reload nginx.service to apply any changes.

Troubleshooting

Check the build options

The following command shows the Tegola version and build tags:

$ sudo -u tegola tegola version

For tegola-headlessAUR, the output should include:

$ sudo -u tegola tegola version
version: v0.21.0
build tags: ... !noPostgisProvider ... !noViewer ...
ui viewer: viewer not built

The !noPostgisProvider build tag means that the PostGIS provider is included.

The ui viewer: viewer not built line is expected for the headless package.

Permission denied for the configuration file

If the service fails with an error similar to:

error opening local config file (/etc/tegola/tegola.toml): permission denied

check the file ownership and permissions:

$ sudo ls -ld /etc/tegola
$ sudo ls -l /etc/tegola/tegola.toml

The tegola user must be able to read the configuration file.

View logs

Use journalctl to inspect service logs:

$ journalctl -u tegola.service -n 100 --no-pager

See also