我正在使用HAProxy负载平衡一些Web服务器(HTTP模式)。 Web服务器是严格dynamic的,即没有任何静态内容,只有Web服务。
types的URL(类似)
http://192.168.5.10:8080/small http://192.168.5.10:8080/medium http://192.168.5.10:8080/large
现在,当我configurationHAProxy将传入的请求转发到这几个机器上的这三个url,我使用acl和path_end / path_beg指定了path_beg ,但是在发出请求时,我得到了Not Found on Accelerator错误,这使得它更难以指出问题。
以下是我正在使用的configuration。 此外,它不logging任何错误。
global log 127.0.0.1 local0 log 127.0.0.1 local1 notice maxconn 4096 user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull retries 3 option redispatch maxconn 2000 contimeout 5000 clitimeout 10000 srvtimeout 10000 frontend http_proxy bind 192.168.5.9:8888 acl is_small path_end -i small acl is_medium path_end -i medium acl is_large path_end -i large use_backend web_server_small if is_small use_backend web_server_medium if is_medium use_backend web_server_large if is_large backend web_server_small mode http balance roundrobin option httpclose server web_1 192.168.5.10:8080 check server web_2 192.168.5.11:8080 check backend web_server_medium mode http balance roundrobin option httpclose server web_1 192.168.5.12:8080 check server web_2 192.168.5.13:8080 check backend web_server_large mode http balance roundrobin option httpclose server web_1 192.168.5.14:8080 check server web_2 192.168.5.15:8080 check
是否可以通过url_path将请求从HAProxy发送到web_server?
如果HAProxy接收到http://192.168.5.2:80/small ,则发送请求到networking服务器http://192.168.5.10:8080/small
由于您的path包含在URL的开头,为什么不使用path_beg,build议将path_end用于文件扩展名。
acl is_small path_beg -i / small
acl is_medium path_beg -i / medium
acl is_large path_beg -i / large
HTTP请求的path总是交给后端服务器,
GET /small HTTP/1.1
将在HAproxy后面可见,就像这个请求一样。 如果你怀疑这个不知何故被截断
GET / HTTP/1.1
在HAproxy后面的服务器上,你应该检查这个使用
tcpdump -i any port 8080 -As1024 | grep GET
在该服务器上,并观看入站GET请求。
我正在做一个假设,并且假设你希望HAproxy在URI的前面插入一些东西,比如
server web_1 192.168.5.14:8080/my/path check
将请求/small变成请求/my/path/small 。 这可以通过使用reqrep选项来实现,详情请参阅文档 。