File size: 4,878 Bytes
3c35cc6 b5bd2cf 3c35cc6 b5bd2cf 3c35cc6 d97bb06 b5bd2cf d97bb06 b5bd2cf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | proxy_cache_path /data/cache/tiles levels=1:2 keys_zone=gibs:64m max_size=3g
inactive=30d use_temp_path=off;
# 全球极端事件平台
# / Shadowbroker(Next.js,根路径,预构建镜像无法改 basePath)
# /cdhe/ 自建 CDHE 四态看板(静态)
# /wm/ worldmonitor(静态构建,若可用)
upstream shadowbroker_fe { server 127.0.0.1:3000; keepalive 16; }
upstream shadowbroker_be { server 127.0.0.1:8000; keepalive 16; }
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
charset utf-8;
client_max_body_size 64m;
access_log /data/logs/nginx.access.log;
error_log /data/logs/nginx.error.log warn;
gzip on;
gzip_comp_level 5;
gzip_types text/plain text/css application/json application/javascript application/wasm image/svg+xml;
gzip_min_length 1024;
# ---------- NASA GIBS 卫星底图(本机缓存,避免每次回源) ----------
location ^~ /tiles/gibs/ {
proxy_pass https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/;
proxy_ssl_server_name on;
proxy_set_header Host gibs.earthdata.nasa.gov;
proxy_set_header User-Agent "GeoEvents/1.0";
proxy_cache gibs;
proxy_cache_key "$uri";
proxy_cache_valid 200 30d;
proxy_ignore_headers Cache-Control Expires Set-Cookie;
proxy_cache_use_stale error timeout updating;
proxy_cache_lock on;
add_header X-Cache $upstream_cache_status;
expires 7d;
}
# ---------- 自建 CDHE 看板 ----------
# alias + try_files 在 nginx 1.18 下会回落到 index,故只用 alias
location ^~ /cdhe/ {
alias /data/apps/cdhe/www/;
index index.html;
autoindex off;
expires 1h;
add_header Cache-Control "public";
}
location = /cdhe {
return 301 /cdhe/;
}
# ---------- 版本别名(v1 多源 / v2 图层库 / v3 气候 / v4 地球) ----------
location = /v1 { return 302 /; }
location = /v2 { return 302 /wm/; }
location = /v3 { return 302 /cdhe/; }
location = /v4 { return 302 /globe/; }
# ---------- 全球视角 3D 地球(MapLibre globe,静态) ----------
location ^~ /globe/ {
alias /data/apps/globe/;
index index.html;
autoindex off;
expires 5m;
add_header Cache-Control "public";
}
location = /globe {
return 301 /globe/;
}
# ---------- worldmonitor 的绝对路径静态资源 ----------
# 前端有若干 fetch('/data/...') 写死绝对路径,base=/wm/ 时打不到,这里补一条映射
location ^~ /data/ {
proxy_pass http://127.0.0.1:3001/wm/data/;
proxy_http_version 1.1;
proxy_set_header Host 127.0.0.1:3001;
proxy_read_timeout 120s;
}
# ---------- 中文入口页 ----------
location ^~ /portal/ {
alias /data/apps/portal/;
index index.html;
autoindex off;
}
location = /portal {
return 301 /portal/;
}
# ---------- worldmonitor(vite 开发服务器,base=/wm/) ----------
location ^~ /wm/ {
proxy_pass http://127.0.0.1:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Vite 的 host 校验只认 localhost/127.0.0.1,这里强制改写,否则公网访问 403
proxy_set_header Host 127.0.0.1:3001;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 600s;
proxy_buffering off;
}
# ---------- Shadowbroker 后端 API(显式前缀,便于单独排查) ----------
location /sbapi/ {
proxy_pass http://shadowbroker_be/;
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_read_timeout 300s;
proxy_buffering off;
}
# ---------- Shadowbroker 前端(根路径) ----------
location / {
proxy_pass http://shadowbroker_fe;
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 $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_buffering off;
proxy_cache_bypass $http_upgrade;
}
location = /healthz {
access_log off;
default_type text/plain;
return 200 "ok\n";
}
}
|