-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
49 lines (39 loc) · 1.13 KB
/
nginx.conf
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
server {
listen 80;
server_name 域名;
# 自动将 HTTP 请求重定向到 HTTPS
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name 域名;
root 静态资源路径;
# SSL 证书和私钥文件路径
ssl_certificate certificate.crt证书文件路径;
ssl_certificate_key privatekey.key私钥文件路径;
# 设置支持的 SSL 协议和会话缓存
ssl_protocols TLSv1.2 TLSv1.3;
ssl_session_cache shared:SSL:100m;
ssl_session_timeout 10m;
# 设置请求头字段
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 设置响应头字段
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
# 解除上传文件大小限制
client_max_body_size 0;
# 设置缓存策略
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 1h;
add_header Cache-Control "public";
}
# 反向代理或其他配置规则可以添加在这里
location / {
# 反向代理后端
proxy_pass http://后端地址:后端端口;
# 反向代理前端
try_files $uri $uri/ /index.html;
}
}