<pre name="code" class="html">/***第一种
nginx 配置:
location / {
root /var/www/zjzc-web-frontEnd;
index index.html;
} zjtest7-frontend:/var/www/zjzc-web-frontEnd/images# pwd
/var/www/zjzc-web-frontEnd/images
zjtest7-frontend:/var/www/zjzc-web-frontEnd/images# ls
3.png http://192.168.32.76:8001/images/3.png haproxy: acl image_req path_beg -i /images
use_backend imageserver_8001 if image_req backend imageserver_8001
mode http
balance roundrobin
server webhost01_8001 192.168.32.76:8001 check inter 2000 fall 3 weight 20 haproxy 如果有这行就不行
#acl url_static_zjdev path_end .html .gif .png .jpg .css .js 注释掉这行 /*******************
frontend web_service
bind *:80 acl api_req path_beg -i /api
use_backend appserver_8082 if api_req acl image_req path_beg -i /images
use_backend imageserver_8001 if image_req acl url_static path_end .html .gif .png .jpg .css .js
use_backend webserver_8001 if url_static
backend imageserver_8001
mode http
balance roundrobin
server webhost01_8001 192.168.32.76:8001 check inter 2000 fall 3 weight 20 backend webserver_8001
mode http
balance roundrobin
server webhost01_8001 192.168.32.213:8001 check inter 2000 fall 3 weight 20
#server webhost02_8001 192.168.32.214:8001 check inter 2000 fall 3 weight 20 backend appserver_8082
mode http
balance roundrobin
server apphost01_8082 192.168.32.215:8082 check inter 2000 fall 3 先匹配到/images 就不会继续往下匹配 frontend web_service
bind *:80 acl api_req path_beg -i /api
use_backend appserver_8082 if api_req
acl url_static path_end .html .gif .png .jpg .css .js
use_backend webserver_8001 if url_static acl image_req path_beg -i /images
use_backend imageserver_8001 if image_req backend imageserver_8001
mode http
balance roundrobin
server webhost01_8001 192.168.32.76:8001 check inter 2000 fall 3 weight 20 backend webserver_8001
mode http
balance roundrobin
server webhost01_8001 192.168.32.213:8001 check inter 2000 fall 3 weight 20
#server webhost02_8001 192.168.32.214:8001 check inter 2000 fall 3 weight 20 backend appserver_8082
mode http
balance roundrobin
server apphost01_8082 192.168.32.215:8082 check inter 2000 fall 3 这样情况 http://www.zjtest7.com/images/3.png 就访问不到了,因为先匹配了path_end