dingdanquanliucheng/deploy/nginx-ppyys.conf

77 lines
2.3 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.

server {
listen 80;
server_name ddy.gaowenbu.cn;
# HTTP 强制跳转 HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name ddy.gaowenbu.cn;
# ---------- SSL 证书(宝塔 Let's Encrypt ----------
ssl_certificate /www/server/panel/vhost/cert/ddy.gaowenbu.cn/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/ddy.gaowenbu.cn/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
# ---------- 安全头 ----------
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# ---------- 日志 ----------
access_log /www/wwwlogs/ddy.gaowenbu.cn.log;
error_log /www/wwwlogs/ddy.gaowenbu.cn.error.log;
# ---------- 前端静态文件Vue SPA ----------
root /www/wwwroot/ppyys;
index index.html;
# 前端路由:所有非文件请求回退到 index.htmlVue History 模式)
location / {
try_files $uri $uri/ /index.html;
}
# 静态资源缓存JS/CSS/图片等带 hash 的文件)
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;
}
# 健康检查(无 /api 前缀)
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;
}
# ---------- 禁止访问隐藏文件 ----------
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}