-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf.example
More file actions
81 lines (72 loc) · 2.2 KB
/
Copy pathnginx.conf.example
File metadata and controls
81 lines (72 loc) · 2.2 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# nginx 配置示例
# HTTP 自动跳转 HTTPS
server {
listen 80;
listen [::]:80;
server_name domain.com www.domain.com;
return 301 https://$server_name$request_uri;
}
# HTTPS 主站配置
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name domain.com www.domain.com;
# SSL 证书(泛域名证书)
ssl_certificate /etc/xxx/fullchain.pem;
ssl_certificate_key /etc/xxx/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# 统一站点根目录,仅用于前台
root /var/www/xxx/web/dist;
index index.html;
# 前台静态资源缓存
location ^~ /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# 后台静态资源缓存
location ^~ /admin/assets/ {
alias /var/www/xxx/admin/dist/assets/;
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
# 上传文件
location ^~ /uploads/ {
client_max_body_size 50m;
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_pass http://127.0.0.1:8000/uploads/;
proxy_http_version 1.1;
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;
}
# 后端 API
location ^~ /api/v1/ {
client_max_body_size 50m;
proxy_pass http://127.0.0.1:8000/api/v1/;
proxy_http_version 1.1;
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 ^~ /admin/ {
alias /var/www/xxx/admin/dist/;
index index.html;
try_files $uri $uri/ /admin/index.html;
}
# 允许访问根目录下的静态 txt 文件(不想允许可以注释掉)
location ~* \.txt$ {
root /var/www/xxx;
try_files $uri =404;
}
# 前台安装页与主站
location / {
try_files $uri $uri/ /index.html;
}
}