添加了一个修改
This commit is contained in:
49
nginx.conf.example
Normal file
49
nginx.conf.example
Normal file
@@ -0,0 +1,49 @@
|
||||
# Nginx 配置示例 - 解决 SPA 路由刷新 404 问题
|
||||
# 复制此配置到你的 Nginx 服务器配置中
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name sports.rucky.cn;
|
||||
|
||||
# HTTPS 重定向
|
||||
return 301 https://$server_name$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name sports.rucky.cn;
|
||||
|
||||
# SSL 证书配置
|
||||
ssl_certificate /path/to/your/certificate.crt;
|
||||
ssl_certificate_key /path/to/your/private.key;
|
||||
|
||||
# 网站根目录
|
||||
root /var/www/sports.rucky.cn;
|
||||
index index.html;
|
||||
|
||||
# 关键配置:SPA 路由支持
|
||||
# 所有请求都先尝试文件,如果找不到则返回 index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# 静态资源缓存
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Gzip 压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css text/xml text/javascript
|
||||
application/x-javascript application/xml+rss
|
||||
application/javascript application/json;
|
||||
|
||||
# 安全头
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user