3、使用haproxy的ACL实现基于文件后缀名的动静分离

3、使用haproxyACL实现基于文件后缀名的动静分离

 

 

 

[root@centos7 haproxy]# vim /etc/haproxy/conf.d/test.cfg

frontend magedu_httpd_port

    bind 10.0.0.7:80

    mode http

    balance roundrobin

    log global

    option httplog

####################act setting##################################

acl acl_static path_end -i .jpg .jpeg .png .gif .css .js .html

acl acl_php path_end -i .php

#####################act hosts##################################

use_backend mobile_hosts if acl_static

use_backend app_hosts if acl_php

default_backend pc_hosts

###################### backend hosts #############################

backend mobile_hosts

    mode http

    server web1 10.0.0.17 check inter 2000 fall 3 rise 5

backend pc_hosts

    mode http

    server web2 10.0.0.27:80 check inter 2000 fall 3 rise 5

backend app_hosts

    mode http

server web2 10.0.0.27:80 check inter 2000 fall 3 rise 5

 

 

 

#分别在后端两台主机准备相关文件

[root@centos17 ~]#ls /var/www/html

index.html wang.jpg

 

[root@centos27 ~]#cat /var/www/html/test.php

<?php

echo "<h1>http://10.0.0.27/test.php</h1>\n";

?>

 

 

 

 

posted @   惊起千层浪  阅读(15)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示