-
Notifications
You must be signed in to change notification settings - Fork 537
Expand file tree
/
Copy pathnginx.conf
More file actions
25 lines (21 loc) · 802 Bytes
/
nginx.conf
File metadata and controls
25 lines (21 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# 禁止缓存,确保始终从服务器获取最新内容
add_header Cache-Control no-cache;
# 处理所有路由
location / {
try_files $uri $uri/ /index.html;
# 允许所有跨域请求
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
}
# 配置静态资源缓存
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 1y;
add_header Cache-Control "public, no-transform";
}
}