我试图HAProxy的我WEBAPP(上托管的Tomcat)-reason使用HAProxy的是,它也支持的WebSockets和服务器推送我目前的项目所使用的WebSockets。
第一步,我使用裸露的Web应用程序对其进行了测试-哇,它是如此简单,没有任何麻烦,它可以在大约30分钟内启动并工作。 我使用Linux盒,因为没有适用于Windows的发行版(一个人可以使用cygwin)-我之前的帖子与此相同。
- 下载HAPROXY ,我使用的版本是haproxy-1.4.24。
- 解压tar -xvf haproxy-1.4.24.tar.gz。
- 编译HAPROXY,命令“ make TARGET = linux26”这是针对centos58,Linux内核2.6。 “ TARGET = linux26”中的26表示Linux内核,如果其2.4使用TARGET = linux24”。 作为附带说明,要了解内核,请在您的Linux机器上使用uname -a。
- 将haproxy复制到/ usr / sbin,使用“ cp haproxy / usr / sbin / haproxy”
- 创建一个配置文件,例如/etc/haproxy_chandan.cfg:
- 在HAPROXY 站点上提到的,这是所需的最低配置-将其添加到配置文件
global daemon maxconn 256 defaults mode http timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http-in bind *:80 default_backend websockets_support backend websockets_support server ws1 a.b.c.d:8888 maxconn 32 server ws2 a.b.c.d:8080 maxconn 32 listen admin bind *:8080 stats enable
- 启动HAPROXY,/ usr / sbin / haproxy -f /etc/haproxy_chandan.cfg
- 按照配置,请求将在端口80上处理,而haproxy的管理控制台为8080
- 从http:// ipofmachinewherehaproxy已安装访问您的应用程序:80
- 从http:// ipofmachinewherehaproxy已安装:8080访问haproxy管理控制台
就这样。 继续为WebSockets配置它,看看是否需要其他配置调整或更改-将发布。
翻译自: https://www.javacodegeeks.com/2013/08/haproxy-up-and-running-in-couple-of-minutes.html