mirror of
https://github.com/gadgethd/ukmesh.git
synced 2026-09-01 17:08:17 +00:00
130 lines
4.4 KiB
Plaintext
130 lines
4.4 KiB
Plaintext
geo $mesh_trusted_edge {
|
|
default 0;
|
|
172.30.0.20 1;
|
|
172.30.0.21 1;
|
|
172.18.30.20 1;
|
|
172.18.30.21 1;
|
|
}
|
|
|
|
map "$mesh_trusted_edge:$http_cf_connecting_ip" $mesh_client_ip {
|
|
default $remote_addr;
|
|
~^1:([0-9A-Fa-f:.]+)$ $1;
|
|
}
|
|
|
|
map $uri $mesh_permissions_policy {
|
|
default "geolocation=(), camera=(), microphone=()";
|
|
~^/(feed|repeater)?/?$ "geolocation=(self), camera=(), microphone=()";
|
|
}
|
|
|
|
server {
|
|
listen 8080;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
|
|
# Gzip compression for static assets
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
|
gzip_min_length 256;
|
|
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
|
|
|
# Operator endpoints are never part of the public frontend origin.
|
|
location ~ ^/(local-api|backend|ml-path-learner|operations|observer-registrations|metrics)(/|$) {
|
|
return 404;
|
|
}
|
|
|
|
# WebSocket upgrade — must come before the /api block
|
|
location = /ws {
|
|
set $backend_upstream http://backend:3000;
|
|
proxy_pass $backend_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $mesh_client_ip;
|
|
proxy_set_header X-Forwarded-For $mesh_client_ip;
|
|
proxy_read_timeout 3600s;
|
|
}
|
|
location = /ws/ {
|
|
return 308 /ws;
|
|
}
|
|
|
|
# API and health check proxy to backend
|
|
location ~ ^/(api|healthz|readyz)(/|$) {
|
|
set $backend_upstream http://backend:3000;
|
|
proxy_pass $backend_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $mesh_client_ip;
|
|
proxy_set_header X-Forwarded-For $mesh_client_ip;
|
|
}
|
|
|
|
# OS Terrain 50 terrain tiles (terrarium-encoded PNG)
|
|
location /terrain-tiles/ {
|
|
alias /terrain-tiles/;
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Cache-Control "public, max-age=604800, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# HopReach output volume. Metadata/progress are atomically replaced and
|
|
# must be revalidated; completed PNGs may be cached briefly and are
|
|
# cache-busted by run/tile progress in the native map.
|
|
location = /rf-coverage/meta.json {
|
|
alias /rf-coverage-data/output/meta.json;
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
location = /rf-coverage/progress.json {
|
|
alias /rf-coverage-data/output/progress.json;
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
location ~ ^/rf-coverage/tiles/(standard|precision)/([0-9]+-[0-9]+\.png)$ {
|
|
alias /rf-coverage-data/output/tiles/$1/$2;
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Cache-Control "public, max-age=30, stale-while-revalidate=300";
|
|
}
|
|
location ~ "^/rf-coverage/tiles/nodes/(n[0-9a-f]{24})/([0-9]+-[0-9]+\.png)$" {
|
|
alias /rf-coverage-data/output/tiles/nodes/$1/$2;
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Cache-Control "public, max-age=30, stale-while-revalidate=300";
|
|
}
|
|
location /rf-coverage/ {
|
|
return 404;
|
|
}
|
|
|
|
# robots.txt — disallow indexing of app domains
|
|
location = /robots.txt {
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# SPA fallback
|
|
location / {
|
|
try_files $uri $uri/index.html /index.html;
|
|
}
|
|
|
|
# Cache immutable built assets aggressively.
|
|
location /assets/ {
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# Always revalidate shell + service worker so deploys appear quickly.
|
|
location = /index.html {
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
location = /sw.js {
|
|
include /etc/nginx/snippets/security-headers.conf;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
}
|