Carto Voyager was returning 'API Key required' content for the
user (likely rate-limited or IP-blocked by Carto). Switched to
ESRI World_Street_Map which has CORS-friendly tiles with plenty
of place names and street labels.
URL format is different from Carto: {z}/{y}/{x}.jpg (y before x,
jpg not png). Updated the build to match. The local /esri/
proxy in default.conf handles the upstream CORS-incompatibility
by adding permissive CORS headers and a proper User-Agent.
52 lines
2.1 KiB
Plaintext
52 lines
2.1 KiB
Plaintext
server {
|
|
listen 58881 default_server;
|
|
server_name localhost _;
|
|
root /usr/share/nginx/html;
|
|
index background.html;
|
|
|
|
location / {
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
# CORS proxy for Carto basemaps (place names, OSM-derived).
|
|
# URL format: /carto/voyager/{z}/{x}/{y}.png
|
|
location ^~ /carto/ {
|
|
resolver 1.1.1.1 8.8.8.8 ipv6=off valid=300s;
|
|
proxy_pass https://a.basemaps.cartocdn.com/;
|
|
proxy_ssl_server_name on;
|
|
proxy_set_header Host a.basemaps.cartocdn.com;
|
|
proxy_set_header User-Agent "Mozilla/5.0 (compatible; tile-proxy)";
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
|
|
add_header Access-Control-Max-Age 86400 always;
|
|
}
|
|
|
|
# CORS proxy for ESRI World_Street_Map. URL format:
|
|
# /esri/wsm/{z}/{y}/{x}.jpg -> ESRI /ArcGIS/.../World_Street_Map/.../tile/{z}/{y}/{x}
|
|
location ^~ /esri/ {
|
|
resolver 1.1.1.1 8.8.8.8 ipv6=off valid=300s;
|
|
rewrite ^/esri/streets/(.*)$ /ArcGIS/rest/services/World_Street_Map/MapServer/tile/$1 break;
|
|
rewrite ^/esri/topo/(.*)$ /ArcGIS/rest/services/World_Topo_Map/MapServer/tile/$1 break;
|
|
rewrite ^/esri/imagery/(.*)$ /ArcGIS/rest/services/World_Imagery/MapServer/tile/$1 break;
|
|
proxy_pass https://server.arcgisonline.com;
|
|
proxy_ssl_server_name on;
|
|
proxy_set_header Host server.arcgisonline.com;
|
|
proxy_set_header User-Agent "Mozilla/5.0 (compatible; tile-proxy)";
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
|
|
add_header Access-Control-Max-Age 86400 always;
|
|
}
|
|
|
|
# CORS preflight handler
|
|
location ~* \.(png|jpg)$ {
|
|
if ($request_method = 'OPTIONS') {
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
|
|
add_header Access-Control-Max-Age 86400 always;
|
|
add_header Content-Length 0;
|
|
return 204;
|
|
}
|
|
add_header Access-Control-Allow-Origin "*" always;
|
|
}
|
|
}
|