首页 > 解决方案 > ALB -> HAPROXY Websocket 连接不工作

问题描述

很长一段时间后在社区发帖。我正在尝试设置这样的基础设施。

ALB -> HAPROXY ec2 节点 -> 网络服务器。

我能够成功启动应用程序并通过 http 和 https 访问它。

我试图简单地将 websocket 请求代理到演示回显测试应用程序,但它失败了。我验证了 Haproxy 配置,对我来说看起来不错,但没有任何效果。

这是 Haproxy 配置。


defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend http-traffic
        bind *:80
        acl is_websocket hdr(Upgrade) -i WebSocket
        redirect scheme https if is_websocket
        use_backend websocket if is_websocket
        default_backend tomcat

frontend https-traffic
        bind *:443 ssl crt /etc/ssl/private/mydomain.pem
        reqadd X-Forwarded-Proto:\ https
        acl is_websocket hdr(Upgrade) -i WebSocket
        use_backend websocket if is_websocket
        default_backend tomcat

frontend health
    bind *:8080
    acl backend_dead nbsrv(tomcat) lt 1
    monitor-uri /haproxy_status
    monitor fail if backend_dead

backend tomcat
        reqirep ^([^\ :]*)\ /(.*)       \1\ /ImageServlet\2
        server app-i-0000000000f x.x.x.x:8080 cookie app-i-0000000000f check
        server app-i-0000000000f x.x.x.x:8080 cookie app-i-0000000000f check

backend websocket
    http-request set-header Host demos.kaazing.com
    http-request set-path /echo
    server ws demos.kaazing.com:443/echo ssl verify none

感谢你的帮助。谢谢

标签: amazon-web-serviceswebsockethaproxyaws-application-load-balancer

解决方案


推荐阅读