Getting HAProxy to work with Apache

apache-2.2haproxy

I own a VPS running several websites. One of my websites needs to use Mavin for CometD, but I still have to leave Apache running for the other sites. To do this I'm using HAProxy.

I moved Apache and all it's sites off of port 80 and configured HAProxy to run on there. HAProxy does a fine job of routing the proper stuff to Apache, but Apache gives me "Default web site page" instead of the proper VirtualHost. How can I fix this?

A little bit from my Apache config:

<VirtualHost 64.64.0.102:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /homeexample/public_html/hg
ServerAdmin theron@example.com
<IfModule mod_userdir.c>
    Userdir disabled
    Userdir enabled isbwmp
</IfModule>
<IfModule mod_suphp.c>
    suPHP_UserGroup isbwmp isbwmp
</IfModule>
<IfModule !mod_disable_suexec.c>
    SuexecUserGroup isbwmp isbwmp
</IfModule>
CustomLog /usr/local/apache/domlogs/example.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
CustomLog /usr/local/apache/domlogs/example.com combined
ScriptAlias /cgi-bin/ /home/isbwmp/public_html/cgi-bin/

And a bit from my HAProxy config: (Copied, I don't understand it, really)

frontend http_proxy #arbitrary name for the frontend
    bind *:80 #all interfaces at port 80
    mode http
    option forwardfor
    option http-server-close
    option http-pretend-keepalive
    default_backend twisted #by default forward the requests to apache

    acl req_cometd_path path_beg /comet/
    use_backend cometd if req_cometd_path

    acl req_cometd_host hdr_dom(host) -i comet.ishouldbewritingmypaper.com
    use_backend cometd if req_cometd_host

Best Answer

Fixed it: I just needed to change the vhosts from my IP to 127.0.0.1.