-
Notifications
You must be signed in to change notification settings - Fork 2
/
nginx.conf
40 lines (36 loc) · 1.6 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
server {
listen 80;
server_name localhost;
client_max_body_size 20m;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 7;
gzip_types text/plain text/css text/javascript application/javascript application/json;
gzip_vary on;
location / {
# Docker容器路径(Dockerfile中指定),根据自己实际更改
root /usr/share/nginx/html/;
index index.html index.htm;
try_files $uri $uri/ /index.html;
# 解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题
if (!-e $request_filename) {
rewrite ^(.*)$ /index.html?s=$1 last;
break;
}
}
location ^~ /api/ {
rewrite ^/api(.*) $1 break;
# 代理服务器,如果是同一台服务器,配置成宿主机IP即可,即Docker网络的Gateway
proxy_pass http://172.17.0.1:9000/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}