如何配置HAProxy以将GET和POST HTTP请求发送到两个不同的应用程序服务器 [英] How to configure HAProxy to send GET and POST HTTP requests to two different application servers
本文介绍了如何配置HAProxy以将GET和POST HTTP请求发送到两个不同的应用程序服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用RESTful体系结构.我有两个正在运行的应用程序服务器.一个应仅服务于GET请求,而其他应仅服务于POST请求.我想配置HAProxy以根据上述条件对请求进行负载平衡.请帮助我
I am using RESTful architecture. I have two application servers running. One should serve only GET request and other should serve only POST request. I want to configure HAProxy to loadbalance the requests depending upon the above condition. Please help me
推荐答案
下面是部分HAProxy配置,可以为您完成此操作:
Here's a partial HAProxy configuration which can do this for you:
frontend webserver
bind :80
mode http
acl is_post method POST
use_backend post_app if is_post
default_backend get_app
backend post_app
mode http
option forwardfor
balance source
option httpclose
option httpchk HEAD / HTTP/1.0
server post_app1 172.16.0.11:80 weight 1 check inter 1000 rise 5 fall 1
server post_app2 172.16.0.12:80 weight 1 check inter 1000 rise 5 fall 1
server post_app3 172.16.0.13:80 weight 1 check inter 1000 rise 5 fall 1 backup
backend get_app
mode http
option forwardfor
balance source
option httpclose
option httpchk HEAD / HTTP/1.0
server get_app1 172.16.0.21:80 weight 1 check inter 1000 rise 5 fall 1
server get_app2 172.16.0.22:80 weight 1 check inter 1000 rise 5 fall 1
server get_app3 172.16.0.23:80 weight 1 check inter 1000 rise 5 fall 1 backup
这篇关于如何配置HAProxy以将GET和POST HTTP请求发送到两个不同的应用程序服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文