diff --git a/init-server.py b/init-server.py index 4292fb1..3a1b19e 100755 --- a/init-server.py +++ b/init-server.py @@ -267,11 +267,12 @@ def tile_gen(hostname, user, port): def debug(hostname, user, port): c = get_connection(hostname, user, port) + prepare_shared(c) + upload_http_host_config(c) + prepare_http_host(c) - upload_https_host_files(c) - - # run_http_host_sync(c) + run_http_host_sync(c) sudo_cmd(c, '/data/ofm/venv/bin/python -u /data/ofm/http_host/bin/host_manager.py nginx-sync') diff --git a/scripts/http_host/http_host_lib/nginx.py b/scripts/http_host/http_host_lib/nginx.py index 46484cb..9acb695 100644 --- a/scripts/http_host/http_host_lib/nginx.py +++ b/scripts/http_host/http_host_lib/nginx.py @@ -85,7 +85,7 @@ def write_nginx_config(): def create_nginx_conf(*, template_path, local, domain): - location_str, curl_text = create_location_blocks() + location_str, curl_text = create_location_blocks(local=local, domain=domain) with open(template_path) as fp: template = fp.read() @@ -104,7 +104,7 @@ def create_nginx_conf(*, template_path, local, domain): return curl_text -def create_location_blocks(): +def create_location_blocks(*, local, domain): location_str = '' curl_text = '' @@ -112,7 +112,9 @@ def create_location_blocks(): if not subdir.is_dir(): continue area, version = subdir.name.split('-') - location_str += create_version_location(area, version, subdir) + location_str += create_version_location( + area=area, version=version, subdir=subdir, local=local, domain=domain + ) if not curl_text: curl_text = ( @@ -121,7 +123,7 @@ def create_location_blocks(): f'curl -I https://__DOMAIN__/{area}/{version}/14/8529/5975.pbf' ) - location_str += create_latest_locations() + location_str += create_latest_locations(local=local, domain=domain) with open(NGINX_DIR / 'location_static.conf') as fp: location_str += '\n' + fp.read() @@ -129,20 +131,22 @@ def create_location_blocks(): return location_str, curl_text -def create_version_location(area: str, version: str, subdir: Path) -> str: +def create_version_location( + *, area: str, version: str, subdir: Path, local: str, domain: str +) -> str: run_dir = DEFAULT_RUNS_DIR / area / version if not run_dir.is_dir(): print(f" {run_dir} doesn't exists, skipping") return '' - tilejson_path = run_dir / 'tilejson-tiles-org.json' + tilejson_path = run_dir / f'tilejson-{local}.json' metadata_path = subdir / 'metadata.json' if not metadata_path.is_file(): print(f" {metadata_path} doesn't exists, skipping") return '' - url_prefix = f'https://tiles.openfreemap.org/{area}/{version}' + url_prefix = f'https://{domain}/{area}/{version}' subprocess.run( [ @@ -184,7 +188,7 @@ def create_version_location(area: str, version: str, subdir: Path) -> str: """ -def create_latest_locations() -> str: +def create_latest_locations(*, local: str, domain: str) -> str: location_str = '' local_version_files = OFM_CONFIG_DIR.glob('tileset_version_*.txt') @@ -195,7 +199,7 @@ def create_latest_locations() -> str: print(f' setting latest version for {area}: {version}') run_dir = DEFAULT_RUNS_DIR / area / version - tilejson_path = run_dir / 'tilejson-tiles-org.json' + tilejson_path = run_dir / f'tilejson-{local}.json' assert tilejson_path.is_file() location_str += f""" diff --git a/scripts/http_host/http_host_lib/nginx/cf.conf b/scripts/http_host/http_host_lib/nginx/cf.conf index bca5582..d2347e6 100644 --- a/scripts/http_host/http_host_lib/nginx/cf.conf +++ b/scripts/http_host/http_host_lib/nginx/cf.conf @@ -27,4 +27,10 @@ server { error_log /data/ofm/http_host/logs_nginx/cf-error.log; __LOCATION_BLOCKS__ + + # catch-all block to deny all other requests + location / { + deny all; + error_log /data/ofm/http_host/logs_nginx/__LOCAL__-error.log error; + } } diff --git a/scripts/http_host/http_host_lib/nginx/le.conf b/scripts/http_host/http_host_lib/nginx/le.conf index 093d1f2..a8aefa5 100644 --- a/scripts/http_host/http_host_lib/nginx/le.conf +++ b/scripts/http_host/http_host_lib/nginx/le.conf @@ -35,4 +35,10 @@ server { } __LOCATION_BLOCKS__ + + # catch-all block to deny all other requests + location / { + deny all; + error_log /data/ofm/http_host/logs_nginx/__LOCAL__-error.log error; + } } diff --git a/scripts/http_host/http_host_lib/nginx/location_static.conf b/scripts/http_host/http_host_lib/nginx/location_static.conf index f60792e..be482bb 100644 --- a/scripts/http_host/http_host_lib/nginx/location_static.conf +++ b/scripts/http_host/http_host_lib/nginx/location_static.conf @@ -62,10 +62,3 @@ location @empty_tile { location = / { return 302 https://openfreemap.org; } - -# catch-all block to deny all other requests -location / { - deny all; - - error_log /data/ofm/http_host/logs_nginx/tiles-org-error.log error; -}