这是我的haproxy配置全局日志127.0.0.1 local2 chroot / var / lib / haproxy pidfile /var/run/haproxy.pid maxconn 16384用户haproxy组haproxy守护程序
打开stats unix socket
stats socket /var/run/haproxy.cmd
默认模式http日志全局选项httplog选项dontlognull选项httpclose选项forwardfor除127.0.0.0/8选项redispatch重试3超时http请求10s超时队列1m超时连接20s超时客户端45s超时服务器45s超时检查20s maxconn 16384
listen stats:9000模式http stats启用统计uri / haproxy stats领域HAProxy \ Statistics stats auth haproxy:密码统计admin如果为TRUE
监听http:80 #balance leastconn #balance roundrobin balance source选项http-server-close选项forwardfor server web1 10.0.2.10:8080 check inter 3000 rise 2 fall 3 server web2 10.0.2.11:8080 check inter 3000 rise 2 fall 3
acl has_www hdr_beg(host)-i www
#http-request重定向代码301位置myapp
它的工作方式如下:
我键入http://www.example.com:8000或http://www.example.com所以它转到jboss 's 8080 port. my application is actually accessible through example.com/suite but because the port 80 is blocked by ISP, that'为什么我使用的是端口8000,因为这个;我的应用程序可以通过example.com:8000/mypp访问
我想使用haproxy配置将任何键入example.com:8000的人转发到example.com:8000/myapp
怎么实现呢?我错过了什么?
1 回答
在后端节点部分中定义“服务器”时,可以将URI连接到IP和端口,如下所示,以实现您的目标,