forked from Postcatlab/postcat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.conf.template
86 lines (72 loc) · 2.87 KB
/
default.conf.template
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
82
83
84
85
86
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
absolute_redirect off; #取消绝对路径的重定向
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 256;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location / {
return 301 $scheme://$http_host/zh;
}
location /zh {
alias /usr/share/nginx/html/zh;
index index.html index.htm;
try_files $uri $uri/ /zh/index.html;
}
location /en {
alias /usr/share/nginx/html/en;
index index.html index.htm;
try_files $uri $uri/ /en/index.html;
}
# api测试服务
location /api/unit {
proxy_pass http://eoapi-test-server:$NODE_SERVER_PORT; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# websocket测试服务
location ~/socket.io/(.*) {
proxy_pass http://eoapi-test-server:$POSTCAT_WEBSOCKET_POST; # 转发规则
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
}
# 后端服务
location ^~ /api {
proxy_pass http://eoapi-remote-server:$EOAPI_SERVER_PORT; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 后端服务兼容旧客户端
location ~ ^/(system|workspace|user|auth|mock|[0-9]+/[0-9]+/api_data|[0-9]+/[0-9]+/group|[0-9]+/[0-9]+/group|[0-9]+/[0-9]+/environment|[0-9]+/[0-9]+/api_test_history|[0-9]+/[0-9]+/mock|[0-9]+/[0-9]+/shared|[0-9]+/project) {
proxy_pass http://eoapi-remote-server:$EOAPI_SERVER_PORT; # 转发规则
proxy_set_header Host $proxy_host; # 修改转发请求头,让3000端口的应用可以受到真实的请求
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite "^/(.*)$" /api/$1 break;
}
# location ^~ /zh/(.*)/assets/(.*)$ {
# alias /usr/share/nginx/html/zh/assets/$2;
# return 501 /usr/share/nginx/html/zh/assets/$2;
#}
# location ^~ /zh/\.(gif|jpg|jpeg|png|css|js|ico|svg|ttf|woff2|woff|txt)$ {
# alias /usr/share/nginx/html/zh/$1;
# return 502 /usr/share/nginx/html/zh/$1;
#}
}