70 lines
1.9 KiB
Plaintext
70 lines
1.9 KiB
Plaintext
# 管理员端 - dda.gaowenbu.cn(HTTP 版,申请 SSL 后再改 HTTPS)
|
||
server {
|
||
listen 80;
|
||
server_name dda.gaowenbu.cn;
|
||
|
||
# ---------- 日志 ----------
|
||
access_log /www/wwwlogs/dda.gaowenbu.cn.log;
|
||
error_log /www/wwwlogs/dda.gaowenbu.cn.error.log;
|
||
|
||
# ---------- 前端静态文件(管理员端) ----------
|
||
root /www/wwwroot/dda.gaowenbu.cn;
|
||
index index.html;
|
||
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 静态资源缓存
|
||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?|ttf|eot)$ {
|
||
expires 30d;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
|
||
# ---------- 后端 API 反向代理 ----------
|
||
location /api/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
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;
|
||
client_max_body_size 20m;
|
||
}
|
||
|
||
# ---------- WebSocket 反向代理 ----------
|
||
location /ws/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
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 86400s;
|
||
proxy_send_timeout 86400s;
|
||
}
|
||
|
||
location = /health {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_set_header Host $host;
|
||
}
|
||
|
||
location /uploads/ {
|
||
proxy_pass http://127.0.0.1:8000;
|
||
proxy_set_header Host $host;
|
||
}
|
||
|
||
# Let's Encrypt 文件验证
|
||
location ~ /\.well-known {
|
||
allow all;
|
||
}
|
||
|
||
# 禁止访问其他隐藏文件
|
||
location ~ /\. {
|
||
deny all;
|
||
access_log off;
|
||
log_not_found off;
|
||
}
|
||
}
|