Spaces:
Sleeping
Sleeping
Create nginx.conf
Browse files- nginx.conf +40 -0
nginx.conf
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
server {
|
| 2 |
+
listen 3000 default_server;
|
| 3 |
+
listen [::]:80 default_server;
|
| 4 |
+
server_name _;
|
| 5 |
+
root /usr/share/nginx/html;
|
| 6 |
+
index index.html;
|
| 7 |
+
|
| 8 |
+
# 安全相关的HTTP头
|
| 9 |
+
add_header X-Content-Type-Options "nosniff";
|
| 10 |
+
add_header X-Frame-Options "SAMEORIGIN";
|
| 11 |
+
add_header X-XSS-Protection "1; mode=block";
|
| 12 |
+
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
| 13 |
+
|
| 14 |
+
# 特殊处理config.js,防止缓存
|
| 15 |
+
location = /config.js {
|
| 16 |
+
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
|
| 17 |
+
expires -1;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
# 缓存静态资源
|
| 21 |
+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
| 22 |
+
expires max;
|
| 23 |
+
add_header Cache-Control "public, max-age=31536000, immutable";
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
# SPA路由处理
|
| 27 |
+
location / {
|
| 28 |
+
try_files $uri $uri/ /index.html;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
# 健康检查
|
| 32 |
+
location /health {
|
| 33 |
+
return 200 'ok';
|
| 34 |
+
add_header Content-Type text/plain;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
# 日志配置
|
| 38 |
+
access_log /var/log/nginx/access.log;
|
| 39 |
+
error_log /var/log/nginx/error.log;
|
| 40 |
+
}
|