配置如下
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
|
server {
listen 80;
server_name xxxxxxxx;
access_log
/var/log/nginx/inetrnal_access
.log main;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
#proxy_next_upstream error timeout http_500 http_502 http_503 http_504 http_404;
add_header X-Cache
"$upstream_cache_status from $server_addr"
;
client_max_body_size 20m;
location ~* ^/([A-Za-z0-9\-.]*) {
proxy_pass http:
//fujie_
$1;
}
allow 10.0.0.0
/8
;
deny all;
}
upstream fujie_ues-ws {
sticky;
server xxxxxxxx:8160 max_fails=3 fail_timeout=2;
server xxxxxxxx:8160 max_fails=3 fail_timeout=2;
}
upstream fujie_mns-web {
sticky;
server xxxxxxxx:8156 max_fails=3 fail_timeout=2;
server xxxxxxxx:8156 max_fails=3 fail_timeout=2;
}
upstream fujie_ufs {
sticky;
server xxxxxxxx:8090 max_fails=3 fail_timeout=2;
server xxxxxxxx:8090 max_fails=3 fail_timeout=2;
}
|
location 那段的意思是,忽略大小写,路径匹配所有大小写字符和数字,以及横岗 后的任意一个字符,匹配任意数量
而方向代理的$1变量是location的路径的第一个参数,也就是正则匹配到的字符串
本文转自wks9751CTO博客,原文链接:http://blog.51cto.com/wks97/2085573 ,如需转载请自行联系原作者