1
0

feat: add nginx router config file for backend and frontend

This commit is contained in:
2026-05-11 22:28:08 +08:00
parent 07205396c8
commit 24790d8e69
3 changed files with 61 additions and 14 deletions

61
tools/.nginx.conf Normal file
View File

@@ -0,0 +1,61 @@
# ============================
# 路由 1: /web -> 静态文件
# ============================
location /web {
# 使用 alias 精确映射
# 请求 /web/index.html -> /var/www/static/index.html
alias /var/www/static;
# 静态文件优化
expires 7d;
add_header Cache-Control "public, max-age=604800";
# 尝试返回文件不存在则返回404避免落入其他location
try_files $uri $uri/ =404;
# 可选:启用 gzip 压缩
gzip_static on;
}
# ============================
# 路由 2: /api -> Go 程序 (8848端口)
# ============================
location /api {
# 反向代理到本地 Go 服务
proxy_pass http://127.0.0.1:8848;
# 重要:保留原始请求头
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;
# WebSocket 支持(如果 Go 程序需要)
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# 超时设置(根据业务调整)
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
# 缓冲设置(可选,大文件上传时注意调整)
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 8 4k;
}
# ============================
# 可选:根路径处理
# ============================
location = / {
# 重定向到 /web
return 302 /web/;
}
# 禁止访问隐藏文件
location ~ /\. {
deny all;
return 404;
}

29
tools/dial_plate_gen.py Normal file
View File

@@ -0,0 +1,29 @@
import math
print('Dial Plate Generator')
plateSize = float(input('Plate size: '))
hourInnerRadius = float(input('Hour inner radius percent (float): '))
hourOutterRadius = float(input('Hour outter radius percent (float): '))
minuteRadius = float(input('Minute radius percent (float): '))
halfPlateSize = plateSize / 2
for i in range(24):
rad = math.radians(90 - i * 30)
x = math.cos(rad)
y = math.sin(rad)
radius = halfPlateSize * (hourOutterRadius if i < 12 else hourInnerRadius)
x = x * radius + halfPlateSize
y = (-y * radius) + halfPlateSize
print('<text x="{:.6f}" y="{:.6f}">{}</text>'.format(x, y, i))
print('')
for i in range(12):
rad = math.radians(90 - i * 30)
x = math.cos(rad)
y = math.sin(rad)
radius = minuteRadius * halfPlateSize
x = x * radius + halfPlateSize
y = (-y * radius) + halfPlateSize
print('<text x="{:.6f}" y="{:.6f}">{}</text>'.format(x, y, i * 5))