Update the sub_filter pattern for fetch requests to include escaped double quotes. This ensures that path rewriting correctly handles JavaScript fetch calls that use double-quoted strings, preventing broken resource paths in the telemetry dashboard.
86 lines
2.8 KiB
Nginx Configuration File
86 lines
2.8 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /var/lib/nginx/html;
|
|
index index.html;
|
|
|
|
location /api/ {
|
|
proxy_pass http://zeavis-api:3000/api/;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
# Expose API metrics through the web endpoint (Prometheus scrape target)
|
|
location /metrics {
|
|
proxy_pass http://zeavis-api:3000/metrics;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
# ── Telemetry Dashboard Proxy (orange VPS via Tailscale) ──────────────
|
|
# Telemetry UI SPA assets (fingerprinted by Vite, cache aggressively)
|
|
location /telemetry/assets/ {
|
|
proxy_pass http://100.96.248.86:8181/assets/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Telemetry API calls (query proxy + target management)
|
|
location /telemetry/proxy/ {
|
|
proxy_pass http://100.96.248.86:8181/proxy/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_connect_timeout 5s;
|
|
proxy_send_timeout 35s;
|
|
proxy_read_timeout 35s;
|
|
}
|
|
|
|
location /telemetry/api/ {
|
|
proxy_pass http://100.96.248.86:8181/api/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_connect_timeout 5s;
|
|
proxy_send_timeout 10s;
|
|
proxy_read_timeout 10s;
|
|
}
|
|
|
|
# Telemetry SPA — proxy to orange VPS, rewrite root-relative paths to /telemetry/ prefix
|
|
location /telemetry/ {
|
|
proxy_pass http://100.96.248.86:8181/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_connect_timeout 5s;
|
|
proxy_send_timeout 35s;
|
|
proxy_read_timeout 35s;
|
|
|
|
# Rewrite root-relative paths (<script src="/", href="/", fetch("/")) to /telemetry/ prefix
|
|
sub_filter_once off;
|
|
sub_filter 'src="/' 'src="/telemetry/';
|
|
sub_filter 'href="/' 'href="/telemetry/';
|
|
sub_filter "url('/" "url('/telemetry/";
|
|
sub_filter 'fetch("/' "fetch(\"/telemetry/";
|
|
}
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|