Files
map-asset-gateway/config/service.env.example
T
Harmon 46d83145d9 Keep the admin surface local while serving tiles on the LAN
Binding to 0.0.0.0 used to demand credentials because the admin console and
the tile routes shared one listener. That forced a choice between keeping the
console off the network and letting other machines fetch tiles.

Admin routes are now loopback-only by default: the service can bind 0.0.0.0 so
/tiles, /vectors, the catalog and the probes reach the LAN, while /admin and
/api/v1/admin answer 403 to anything arriving from another host. Credentials
are only required when ADMIN_ALLOW_REMOTE=true actually opens the console up,
which is the case worth guarding.

Tests cover both sides: a remote admin request is refused, a remote tile
request still reaches the token check.
2026-10-16 10:41:32 +08:00

73 lines
3.1 KiB
Bash

# Copy this file to config/service.env and adjust the machine-specific paths.
APP_ENV=dev
SERVICE_NAME=basemap-pusher
SERVICE_VERSION=0.2.0
SERVICE_COMMIT=local
API_HOST=127.0.0.1
API_PORT=8910
API_BASE_URL=http://127.0.0.1:8910
TILE_PUBLIC_BASE_URL=http://127.0.0.1:8910
VECTOR_PUBLIC_BASE_URL=http://127.0.0.1:8910
SQLITE_PATH=Z:\Code\tile-server\data\basemap-pusher.db
BASEMAP_SCAN_ROOT=Z:\Code\tile-server\data\tiles
VECTOR_SCAN_ROOT=Z:\Code\tile-server\data\geojson
AUTO_SCAN_ON_START=true
GOCACHE=Z:\Code\tile-server\.gocache
GOMODCACHE=Z:\Code\tile-server\.gomodcache
GOTMPDIR=Z:\Code\tile-server\.gotmp
GOPATH=Z:\Code\tile-server\.gopath
GOPROXY=https://goproxy.cn,direct
GOSUMDB=off
# --- Admin access ---------------------------------------------------------
# The admin console can mint tokens that read every basemap, so it must be
# protected whenever the service is reachable off-host. Binding to a non
# loopback API_HOST without credentials below makes startup fail on purpose.
#
# Browser console: set ADMIN_USER/ADMIN_PASSWORD (HTTP Basic).
# API clients: set ADMIN_TOKEN (Authorization: Bearer <token>).
# Leaving both empty is only allowed on 127.0.0.1 / ::1 / localhost.
#ADMIN_USER=ops
#ADMIN_PASSWORD=change-me
#ADMIN_TOKEN=change-me-too
# Allow admin endpoints from other hosts. Off by default, so the service can
# serve tiles to the LAN while the console stays reachable only on this box.
# Turning it on requires ADMIN_USER/ADMIN_PASSWORD or ADMIN_TOKEN above.
#ADMIN_ALLOW_REMOTE=true
# Comma-separated list of browser origins allowed to call the API. Empty means
# no cross-origin access at all; "*" allows every origin.
#CORS_ALLOWED_ORIGINS=https://maps.example.com
# Lifetime applied to newly created tokens when no explicit expiry is given.
# Use 0 to create tokens that never expire.
TOKEN_DEFAULT_TTL=720h
# --- Resource health & tile jobs -----------------------------------------
# How often catalogued paths are re-stat'ed so a moved/deleted resource is
# flagged before a client hits a 404. Use 0 to disable the periodic pass
# (the "立即巡检资源" button still works).
HEALTH_CHECK_INTERVAL=5m
# Command template that slices a raster into XYZ tiles. Placeholders:
# {input} {output} {zmin} {zmax} {tilesize} {format} {code}
# scripts/gdal2tiles-qgis.bat locates the GDAL bundled with QGIS (the Python
# bindings need the OSGeo4W environment, so a bare gdal2tiles.exe will not work).
TILE_JOB_COMMAND=D:\Code\tile-server\scripts\gdal2tiles-qgis.bat -p mercator -z {zmin}-{zmax} --xyz -w none --tilesize={tilesize} --exclude {input} {output}
# Where per-job stdout/stderr is written. Empty means <scan root>/.tile-jobs.
#TILE_JOB_LOG_DIR=
# Service tokens may carry the "slice" scope so an integration can submit tile
# jobs through POST /api/v1/slice/jobs without holding the admin credential.
# 多源镶嵌:提交多个源影像时,先用它拼成一张 VRT 再切片(逐像素拼接,
# 消除重叠区的瓦片接缝)。{inputs} 会展开成每个源各一个参数。
TILE_JOB_VRT_COMMAND=D:\Code\tile-server\scripts\gdalbuildvrt-qgis.bat -resolution highest {output_vrt} {inputs}