Files
drawlogo/deploy/drawlogo-zhuig-com.conf
T

95 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 画个标 - drawlogo.zhuig.com(纯静态站 + 素材 API + 站点登录)
server {
listen 80;
listen [::]:80;
server_name drawlogo.zhuig.com;
# certbot ACME 验证
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name drawlogo.zhuig.com;
ssl_certificate /etc/letsencrypt/live/drawlogo.zhuig.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/drawlogo.zhuig.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# 安全响应头
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://api.deepseek.com; img-src 'self' data: blob:;" always;
root /opt/drawlogo;
# 默认入口:设计中枢首页(home.html),找不到时回落到 LOGO 工作台
index home.html index.html;
# ===== 站点登录(auth_request 子请求到 Node) =====
location = /_auth {
internal;
proxy_pass http://127.0.0.1:7891/api/v1/auth/verify;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
}
# 登录页、管理后台、品牌资源免系统登录
location = /login.html { }
location = /api-admin.html { }
location ^~ /logo/ { }
# 静态资源(需登录)
location ~* \.(js|css|woff2|ttf|svg|png|jpg|jpeg|gif|ico)$ {
auth_request /_auth;
error_page 401 = @to_login;
expires 30d;
add_header Cache-Control "public, immutable";
}
# HTML 不缓存(需登录)
location ~* \.html$ {
auth_request /_auth;
error_page 401 = @to_login;
add_header Cache-Control "no-cache, no-store, must-revalidate";
}
# 默认首页(需登录)
location / {
auth_request /_auth;
error_page 401 = @to_login;
try_files $uri $uri/ $uri/index.html =404;
}
location @to_login {
return 302 /login.html?next=$uri;
}
# 素材 API 反代(必须 ^~:否则 /api/.../*.svg 会被上面的 \.svg$ 正则截走)
# 不启用系统登录:外部项目用 API Key 鉴权
location ^~ /api/ {
proxy_pass http://127.0.0.1:7891;
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_connect_timeout 10s;
proxy_read_timeout 30s;
proxy_send_timeout 15s;
client_max_body_size 1m;
}
access_log /var/log/nginx/drawlogo_zhuig_access.log;
error_log /var/log/nginx/drawlogo_zhuig_error.log;
}