Hippie with HAProxy

作者:   發佈於:  

I wrote a Web::Hippie-based vanilla web chatroom at http://chat.gugod.org/

However, I just recently know that nginx reverse proxy is only doing HTTP/1.0 to backends. This means apps powered by Web::Hippie simply does not work. If the app need to be available at port 80, nginx is not helpful.

To be more exact, long-poll mode worked and it can be reconnected when cut off by nginx, and then work agan, mxhr is about the same conditions. WebSocket totally fails there. That's just sad. In order to present my app to a port-less URL, I tried to use HAProxy

Here's the relevant pieces I have in my haproxy.cfg

frontend http-in
        bind 11.22.33.44:80
        acl is_chat_gugod_org hdr_end(host) -i chat.gugod.org
        default_backend nginx
        use_backend chat_gugod_org if is_chat_gugod_org

backend chat_gugod_org
        server chat1 127.0.0.1:19200 maxconn 200 check

backend nginx
        server nginx 127.0.0.1:80

My other virtualhost-based websites are still up and running with nginx and I still need them. Therefore I changed all theri listen values to 127.0.0.1:80, while HAproxy binds to the port 80 of my public IP.

The hippie chat app is launched with Server::Starter like this:

start_server --port 19200 -- twiggy