-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
36 lines (30 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
server {
listen 80;
server_name localhost;
#最大报文转发大小,防止图片传不上去服务器
client_max_body_size 15m;
error_log /etc/nginx/error.log error;
# 打开gzip压缩,加快前端文件的传输速度
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
root /usr/share/nginx/html;
# 两个 container 是两台主机,拥有独立的 ip 地址,不要写 127.0.0.1
# 将具有此url后缀的请求转发到docker后端
location /api/ {
proxy_pass http://123.60.215.79:8000; #注意这里/和不加/区别很大
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#配置前端路径映射规则
location / {
try_files $uri $uri/ @router;
index index.html index.htm;
}
location @router {
rewrite ^.*$ /index.html last;
}
}