On Mon 12.10.2009 14:42, Ryan Schlesinger wrote:

It sounds like what you really want is to put apache (or some other
web server) in front of haproxy to do name based virtual hosting.
Requests for your two domains would work like this:

client -> apache:80 (domain1 virtual host) -> haproxy:8080
client -> apache:80 (domain2 virtual host) -> haproxy:8081

I'm using mod_rewrite in different virtual hosts to proxy requests to
haproxy in exactly this way.  Also, in this setup, a request to
http://ec2XXXXXXXXXX.compute-1.amazonaws.com
<http://ec2XXXXXXXXXX.compute-1.amazonaws.com/xhaproxy214591>/xhaproxy214591
<http://ec2XXXXXXXXXX.compute-1.amazonaws.com/xhaproxy214591> would be
caught by your first (default) virtual host and proxied correctly to
haproxy.

How about to use

http://haproxy.1wt.eu/download/1.3/doc/configuration.txt
7.5.3. Matching at Layer 7

###
frontend public
         bind <IP>:80
.
.
.
acl dom1 path_dom domain1
acl dom2 path_dom domain2
acl domN path_dom domainN

use_backend bd1 if dom1
use_backend bd2 if dom2
use_backend bdN if domN
use_backend default

backend bd1
.
.

backend bd2
.
.

backend bdN
.
.

backend default
.
.
###

In the src you can find an example in examples/acl-content-sw.cfg

I hope I understood your question correctly.

M2.

Hth

Aleks

On 10/12/2009 02:30 PM, Xia Jiang wrote:

Hello,

I have a question regarding configuration for multiple applications using Haproxy.

What I want: use Haproxy to handle LB among multiple instances, which each instance can have more than one servers.

What I have:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Configuration for one application:

listen domain1 :8080

        mode http

        balance roundrobin

        option httpclose

        option forwardfor

        stats uri /xhaproxy214591

        option httpchk GET /healthcheck214591.php

        # Example server line (with optional cookie and check included)

server i-41319a29 10.251.75.47:80 check inter 3000 rise 2 fall 3 maxconn 650

server i-41319a29 10.251.75.48:80 check inter 3000 rise 2 fall 3 maxconn 650

listen domain2 :8081

        mode http

        balance roundrobin

        option httpclose

        option forwardfor

        stats uri /xhaproxy214591

        option httpchk GET /healthcheck214591.php

        # Example server line (with optional cookie and check included)

server i-71319a19 10.208.217.220:80 check inter 3000 rise 2 fall 3 maxconn 650

server i-71319a19 10.208.218.220:80 check inter 3000 rise 2 fall 3 maxconn 650

Question:

1. Do I have to set the one of the application port numbers to be 80? Otherwise it won't show me the status page.

2. By setting one of the port number to be "80", I can't access the other application.

i.e, by setting domain1 port number to be 80, by hitting http://ec2XXXXXXXXXX.compute-1.amazonaws.com, I can see the index page of "10.251.75.47" or "10.251.75.48" but I can't view "10.208.217.220" or "10.208.218.220" by hitting http://ec2XXXXXXXXXX.compute-1.amazonaws.com:8081

Thanks!

Your answer will be greatly appreciated.

Xia


Reply via email to