135 lines
3.6 KiB
Plaintext
135 lines
3.6 KiB
Plaintext
# 开发服无域名时使用的 HTTP 入口,只允许用于 DEPLOY_TARGET=development。
|
|
# 没有域名时,将 SERVER_NAME 填为开发机 IP 或临时主机名。
|
|
# 生产 release 仍必须使用 genarrative.conf 的 HTTPS 配置。
|
|
server {
|
|
listen 80;
|
|
server_name genarrative.example.com;
|
|
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 5;
|
|
gzip_min_length 1024;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/javascript
|
|
application/javascript
|
|
application/json
|
|
application/xml
|
|
application/xml+rss
|
|
image/svg+xml;
|
|
|
|
# __GENARRATIVE_BROTLI_DIRECTIVES__
|
|
|
|
root /srv/genarrative/web;
|
|
index index.html;
|
|
|
|
include /etc/nginx/snippets/genarrative-maintenance.conf;
|
|
|
|
location ^~ /admin/api/ {
|
|
default_type application/json;
|
|
|
|
if ($genarrative_maintenance) {
|
|
return 503 '{"ok":false,"error":{"code":"MAINTENANCE","message":"服务维护中"}}';
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:8082/admin/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_set_header X-Request-Id $request_id;
|
|
}
|
|
|
|
location = /admin {
|
|
return 301 /admin/;
|
|
}
|
|
|
|
location ^~ /admin/assets/ {
|
|
try_files $uri =404;
|
|
}
|
|
|
|
location ^~ /admin/ {
|
|
error_page 503 /maintenance.html;
|
|
|
|
if ($genarrative_maintenance) {
|
|
return 503;
|
|
}
|
|
|
|
try_files $uri $uri/ /admin/index.html;
|
|
}
|
|
|
|
location ^~ /assets/ {
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# 临时兼容主站仍在使用的 /api/* HTTP facade;前端完成 SpacetimeDB SDK 迁移后删除。
|
|
location ~ ^/api(?:/|$) {
|
|
default_type application/json;
|
|
|
|
if ($genarrative_maintenance) {
|
|
return 503 '{"ok":false,"error":{"code":"MAINTENANCE","message":"服务维护中"}}';
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:8082;
|
|
proxy_http_version 1.1;
|
|
proxy_buffering off;
|
|
proxy_read_timeout 3600s;
|
|
proxy_send_timeout 3600s;
|
|
add_header X-Accel-Buffering no always;
|
|
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_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Request-Id $request_id;
|
|
}
|
|
|
|
# 开发服仍不恢复旧生成资源代理和健康检查公网入口。
|
|
location ~ ^/(generated-|healthz) {
|
|
return 404;
|
|
}
|
|
|
|
# 仅开放前端 SpacetimeDB SDK 运行所需的最小公网路由。
|
|
location ~ ^/v1/database/[^/]+/subscribe$ {
|
|
if ($genarrative_maintenance) {
|
|
return 503;
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:3101;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_read_timeout 3600s;
|
|
}
|
|
|
|
location ^~ /v1/identity {
|
|
if ($genarrative_maintenance) {
|
|
return 503;
|
|
}
|
|
|
|
proxy_pass http://127.0.0.1:3101;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
location ^~ /v1/ {
|
|
return 404;
|
|
}
|
|
|
|
location / {
|
|
error_page 503 /maintenance.html;
|
|
|
|
if ($genarrative_maintenance) {
|
|
return 503;
|
|
}
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|