diff --git a/scripts/http_host/http_host_lib/nginx.py b/scripts/http_host/http_host_lib/nginx.py index 37aaf18..e665eca 100644 --- a/scripts/http_host/http_host_lib/nginx.py +++ b/scripts/http_host/http_host_lib/nginx.py @@ -69,9 +69,9 @@ def create_version_location(area: str, version: str, subdir: Path) -> str: return f""" location = /{area}/{version} {{ # no trailing slash alias {tilejson_path}; # no trailing slash - default_type application/json; expires 1d; # TODO target 1w + default_type application/json; add_header 'Access-Control-Allow-Origin' '*' always; add_header Cache-Control public; @@ -79,11 +79,15 @@ def create_version_location(area: str, version: str, subdir: Path) -> str: location /{area}/{version}/ {{ # trailing slash alias {subdir}/tiles/; # trailing slash - try_files $uri @empty; + try_files $uri @empty_tile; add_header Content-Encoding gzip; expires 1d; # TODO target 10y + types {{ + application/vnd.mapbox-vector-tile pbf; + }} + add_header 'Access-Control-Allow-Origin' '*' always; add_header Cache-Control public; }} @@ -107,9 +111,9 @@ def create_latest_locations() -> str: location_str += f""" location = /{area} {{ # no trailing slash alias {tilejson_path}; # no trailing slash - default_type application/json; expires 1d; + default_type application/json; add_header 'Access-Control-Allow-Origin' '*' always; add_header Cache-Control public; diff --git a/scripts/http_host/http_host_lib/templates/nginx_cf.conf b/scripts/http_host/http_host_lib/templates/nginx_cf.conf index b6f32fe..afc66f2 100644 --- a/scripts/http_host/http_host_lib/templates/nginx_cf.conf +++ b/scripts/http_host/http_host_lib/templates/nginx_cf.conf @@ -25,12 +25,24 @@ server { ___LOCATION_BLOCKS___ + location /styles/ { + # trailing slash + + alias /data/ofm/http_host/assets/styles/ofm/; # trailing slash + try_files $uri.json =404; + + expires 1d; + default_type application/json; + + add_header 'Access-Control-Allow-Origin' '*' always; + add_header Cache-Control public; + } + location /fonts/ { # trailing slash alias /data/ofm/http_host/assets/fonts/; # trailing slash try_files $uri =404; - default_type application/x-protobuf; expires 1d; # target 1w @@ -63,11 +75,11 @@ server { } # we need to handle missing tiles as valid request returning empty string - location @empty { - default_type application/vnd.mapbox-vector-tile; + location @empty_tile { return 200 ''; expires 10y; + default_type application/vnd.mapbox-vector-tile; add_header 'Access-Control-Allow-Origin' '*' always; add_header Cache-Control public; diff --git a/ssh_lib/assets/nginx/nginx.conf b/ssh_lib/assets/nginx/nginx.conf index 38a9c58..5e83c8c 100644 --- a/ssh_lib/assets/nginx/nginx.conf +++ b/ssh_lib/assets/nginx/nginx.conf @@ -23,7 +23,7 @@ http { include /etc/nginx/mime.types; types { - application/vnd.mapbox-vector-tile pbf; + application/x-protobuf pbf; } default_type application/octet-stream;