-
Notifications
You must be signed in to change notification settings - Fork 4
/
exile_nginx_for_server.conf
53 lines (45 loc) · 1.88 KB
/
exile_nginx_for_server.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
50
51
52
53
upstream flask_server {
server 106.75.174.40:5000;
# server 120.24.214.173:5001;
# server 120.24.214.173:5002;
# server 120.24.214.173:5003;
}
server {
listen 80;
server_name 106.75.174.40;
charset utf-8;
client_max_body_size 75M;
# 前端页面
location / {
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; # 允许请求方法
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000; # OPTIONS 请求的有效期,在有效期内不用发出另一条预检请求
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 200;
}
root /srv/dist; # 前端打包完成的文件路径
index index.html index.htm;
try_files $uri $uri/ /index.html; # 官网介绍设置这条可以解决history路由的问题
expires -1; # 首页一般没有强制缓存
add_header Cache-Control no-cache;
access_log /srv/logs/access.log;
error_log /srv/logs/err.log;
}
# 后端接口
location /api/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://flask_server;
}
# Web静态资源
location /assets {
alias /srv/dist/assets; # 静态资源目录
autoindex on; # 开启静态资源列目录
autoindex_exact_size off; # on(默认)显示文件的确切大小,单位是byte;off显示文件大概大小,单位KB、MB、GB
autoindex_localtime off; # off(默认)时显示的文件时间为GMT时间;on显示的文件时间为服务器时间
}
# HTML测试报告静态资源
location /report_static {
alias /srv/project_static;
}
}