mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-22 06:22:16 +00:00
nginx work
This commit is contained in:
@@ -66,25 +66,24 @@ def create_version_location(area: str, version: str, subdir: Path) -> str:
|
|||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO # target 10y
|
|
||||||
return f"""
|
return f"""
|
||||||
location /{area}/{version} {{ # no trailing hash
|
location = /{area}/{version} {{ # no trailing hash
|
||||||
alias {tilejson_path}; # no trailing hash
|
alias {tilejson_path}; # no trailing hash
|
||||||
default_type application/json;
|
default_type application/json;
|
||||||
|
|
||||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
add_header Cache-Control public;
|
add_header Cache-Control public;
|
||||||
expires 1d;
|
expires 1d; # TODO target 1w
|
||||||
}}
|
}}
|
||||||
|
|
||||||
location /{area}/{version}/ {{ # trailing hash
|
location /{area}/{version}/ {{ # trailing hash
|
||||||
alias {subdir}/tiles/; # trailing hash
|
alias {subdir}/tiles/; # trailing hash
|
||||||
try_files $uri @empty;
|
try_files $uri @empty;
|
||||||
|
|
||||||
add_header Content-Encoding gzip;
|
add_header Content-Encoding gzip;
|
||||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
add_header Cache-Control public;
|
add_header Cache-Control public;
|
||||||
expires 1d; # target 10y
|
expires 1d; # TODO target 10y
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -104,7 +103,7 @@ def create_latest_locations() -> str:
|
|||||||
assert tilejson_path.exists()
|
assert tilejson_path.exists()
|
||||||
|
|
||||||
location_str += f"""
|
location_str += f"""
|
||||||
location /{area} {{ # no trailing hash
|
location = /{area} {{ # no trailing hash
|
||||||
alias {tilejson_path}; # no trailing hash
|
alias {tilejson_path}; # no trailing hash
|
||||||
default_type application/json;
|
default_type application/json;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def set_tileset_versions():
|
|||||||
local_version_start = fp.read()
|
local_version_start = fp.read()
|
||||||
|
|
||||||
if not remote_version:
|
if not remote_version:
|
||||||
print(' remote version not specified')
|
print(' remote version not specified')
|
||||||
if local_version_start is not None:
|
if local_version_start is not None:
|
||||||
local_version_file.unlink()
|
local_version_file.unlink()
|
||||||
need_nginx_sync = True
|
need_nginx_sync = True
|
||||||
@@ -31,7 +31,7 @@ def set_tileset_versions():
|
|||||||
|
|
||||||
mnt_file = Path(f'/mnt/ofm/{area}-{remote_version}/metadata.json')
|
mnt_file = Path(f'/mnt/ofm/{area}-{remote_version}/metadata.json')
|
||||||
if not mnt_file.exists():
|
if not mnt_file.exists():
|
||||||
print(' local version does not exist')
|
print(' local version does not exist')
|
||||||
if local_version_start is not None:
|
if local_version_start is not None:
|
||||||
local_version_file.unlink()
|
local_version_file.unlink()
|
||||||
need_nginx_sync = True
|
need_nginx_sync = True
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ server {
|
|||||||
ssl_certificate /data/nginx/certs/openfreemap.org.cert;
|
ssl_certificate /data/nginx/certs/openfreemap.org.cert;
|
||||||
ssl_certificate_key /data/nginx/certs/openfreemap.org.key;
|
ssl_certificate_key /data/nginx/certs/openfreemap.org.key;
|
||||||
ssl_session_timeout 1d;
|
ssl_session_timeout 1d;
|
||||||
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
||||||
ssl_session_tickets off;
|
ssl_session_tickets off;
|
||||||
ssl_protocols TLSv1.3;
|
ssl_protocols TLSv1.3;
|
||||||
ssl_prefer_server_ciphers off;
|
ssl_prefer_server_ciphers off;
|
||||||
|
|
||||||
# access log normally not enabled
|
# access log disabled by default
|
||||||
#access_log /data/ofm/http_host/logs_nginx/tiles-org-access.log access_json buffer=32k;
|
#access_log /data/ofm/http_host/logs_nginx/tiles-org-access.log access_json buffer=32k;
|
||||||
access_log off;
|
access_log off;
|
||||||
|
|
||||||
@@ -25,6 +25,17 @@ server {
|
|||||||
|
|
||||||
___LOCATION_BLOCKS___
|
___LOCATION_BLOCKS___
|
||||||
|
|
||||||
|
location /fonts/ {
|
||||||
|
# trailing hash
|
||||||
|
alias /data/ofm/http_host/assets/fonts/; # trailing hash
|
||||||
|
try_files $uri =404;
|
||||||
|
default_type application/x-protobuf;
|
||||||
|
|
||||||
|
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||||
|
add_header Cache-Control public;
|
||||||
|
expires 1d; # target 1w
|
||||||
|
}
|
||||||
|
|
||||||
# we need to handle missing tiles as valid request returning empty string
|
# we need to handle missing tiles as valid request returning empty string
|
||||||
location @empty {
|
location @empty {
|
||||||
default_type application/vnd.mapbox-vector-tile;
|
default_type application/vnd.mapbox-vector-tile;
|
||||||
@@ -34,4 +45,13 @@ server {
|
|||||||
add_header Cache-Control public;
|
add_header Cache-Control public;
|
||||||
expires 10y;
|
expires 10y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location = / {
|
||||||
|
return 302 https://openfreemap.org;
|
||||||
|
}
|
||||||
|
|
||||||
|
# catch-all block to deny all other requests
|
||||||
|
location / {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,9 @@ http {
|
|||||||
'"http_cf_ipcountry": "$http_cf_ipcountry"'
|
'"http_cf_ipcountry": "$http_cf_ipcountry"'
|
||||||
'}';
|
'}';
|
||||||
|
|
||||||
access_log /data/nginx/logs/nginx-access.log access_json buffer=32k;
|
# access log disabled by default
|
||||||
|
#access_log /data/nginx/logs/nginx-access.log access_json buffer=32k;
|
||||||
|
access_log off;
|
||||||
|
|
||||||
include /data/nginx/config/*;
|
include /data/nginx/config/*;
|
||||||
include /data/nginx/sites/*;
|
include /data/nginx/sites/*;
|
||||||
|
|||||||
Reference in New Issue
Block a user