update at 2026-02-08 22:31:25

This commit is contained in:
douboer
2026-02-08 22:31:25 +08:00
parent 0f5a7f0d85
commit f078dd3261
39 changed files with 587 additions and 213 deletions

View File

@@ -1,5 +1,5 @@
# Font2SVG - Nginx 配置fonts.biboer.cn
# 用途:为微信小程序提供 fonts.json 与字体文件静态托管
# 用途:为微信小程序提供静态字体资源 + 远端 SVG 渲染 API
server {
listen 80;
@@ -30,8 +30,8 @@ server {
# 小程序跨域访问
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS" always;
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type" always;
add_header Access-Control-Allow-Methods "GET,HEAD,POST,OPTIONS" always;
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type,Authorization" always;
add_header Access-Control-Expose-Headers "Content-Length,Content-Range" always;
# MIME
@@ -44,8 +44,12 @@ server {
application/vnd.ms-fontobject eot;
}
# SVG 渲染 API独立 Python 服务)
location /api/ {
# SVG 渲染 API独立 Python 服务systemd 监听 127.0.0.1:9300
location ^~ /api/ {
# 预检请求:直接返回 204CORS 头由 server 级 add_header 提供)
if ($request_method = OPTIONS) {
return 204;
}
proxy_pass http://127.0.0.1:9300;
proxy_http_version 1.1;
proxy_set_header Host $host;
@@ -57,13 +61,23 @@ server {
proxy_read_timeout 60s;
}
# 健康检查(可选)
location = /healthz {
proxy_pass http://127.0.0.1:9300/healthz;
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;
}
# fonts.json短缓存便于更新
location = /fonts.json {
expires 1h;
add_header Cache-Control "public, must-revalidate";
add_header Cache-Control "public, must-revalidate" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS" always;
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type" always;
add_header Access-Control-Allow-Methods "GET,HEAD,POST,OPTIONS" always;
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type,Authorization" always;
add_header Access-Control-Expose-Headers "Content-Length,Content-Range" always;
try_files $uri =404;
}
@@ -71,27 +85,16 @@ server {
# 字体文件:长缓存
location ~* \.(ttf|otf|woff|woff2|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
add_header Cache-Control "public, immutable" always;
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS" always;
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type" always;
add_header Access-Control-Allow-Methods "GET,HEAD,POST,OPTIONS" always;
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type,Authorization" always;
add_header Access-Control-Expose-Headers "Content-Length,Content-Range" always;
try_files $uri =404;
}
# 默认仅允许静态文件
# 默认仅提供静态文件
location / {
# 处理预检请求if 在 location 内合法)
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET,HEAD,OPTIONS";
add_header Access-Control-Allow-Headers "Origin,Range,Accept,Content-Type";
add_header Access-Control-Max-Age 1728000;
add_header Content-Length 0;
add_header Content-Type "text/plain; charset=utf-8";
return 204;
}
try_files $uri =404;
}