xiaso-flnxi-website/nginx-no-cache.conf
Your Name b1eab32c75 初始提交: FLNXI电商素材系统官方网站
- Next.js 项目框架
- 完整的认证系统集成
- 数据库配置和部署脚本
- 产品价格体系和文档
- Docker 部署配置
2025-12-13 21:38:32 +08:00

117 lines
3.7 KiB
Plaintext
Raw Permalink 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.

# FLNXI Nginx 配置 - 禁用所有缓存
# 配置文件路径: /www/server/panel/vhost/nginx/scs.flnxi.com.conf
# HTTP 强制跳转 HTTPS
server {
listen 80;
server_name scs.flnxi.com;
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS 主服务
server {
listen 443 ssl http2;
server_name scs.flnxi.com;
# SSL 证书配置
ssl_certificate /www/server/panel/vhost/cert/scs.flnxi.com/fullchain.pem;
ssl_certificate_key /www/server/panel/vhost/cert/scs.flnxi.com/privkey.pem;
# SSL 优化配置
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
# 安全头配置
add_header Strict-Transport-Security "max-age=31536000" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# ========== 禁用所有缓存配置 ==========
# 禁用代理缓存
proxy_cache off;
proxy_no_cache 1;
proxy_cache_bypass 1;
# 禁用浏览器缓存(针对 HTML 文件)
location / {
proxy_pass http://127.0.0.1:4782;
proxy_http_version 1.1;
# WebSocket 支持
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_cache off;
proxy_no_cache 1;
proxy_cache_bypass 1;
# 禁用浏览器缓存(HTML/JSON等动态内容)
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
add_header Pragma "no-cache" always;
add_header Expires "0" always;
# 超时设置
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}
# Next.js 静态资源 - 可以启用长期缓存(这些文件带版本hash)
location /_next/static {
proxy_pass http://127.0.0.1:4782;
proxy_http_version 1.1;
# 静态资源可以缓存,因为文件名包含 hash
add_header Cache-Control "public, max-age=31536000, immutable";
# 其他代理头
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;
}
# 公共静态资源(根据需要调整缓存策略)
location /images {
proxy_pass http://127.0.0.1:4782;
proxy_http_version 1.1;
# 图片资源中等缓存时间
add_header Cache-Control "public, max-age=86400";
# 其他代理头
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;
}
# Gzip 压缩(提升传输速度)
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_min_length 1024;
# 访问日志
access_log /www/wwwlogs/scs.flnxi.com.log;
error_log /www/wwwlogs/scs.flnxi.com.error.log;
}