Thanks, that has cleared that up.

cheers

Chris

On 25 September 2013 16:15, Baptiste <[email protected]> wrote:
> Hi Chris,
>
> Here is what your configuration doing:
> IF there is no 'www.' at the beginning of the Host header, then add it.
> IF there is no 'www.' at the beginning of the Host header, then
> redirect the user to /<url>
>
> Here is how HAProxy works: the request buffer is different from the
> workspace where the rewrite occurs and the rewritten header can't be
> used in next rules.
> Your configuration creates a loop to me: you should be redirected to
> /<url> as long as you don't have a www. in your Host header. And
> obviously the Host header is never changed.
>
> You should be redirecting like this:
> redirect prefix http://www.domain.com code 301 if { hdr(Host) domain.com }
>
> You must create one rule per domain name...
>
> Baptiste
>
>
>
>
> On Wed, Sep 25, 2013 at 9:26 AM, Chris Allison
> <[email protected]> wrote:
>> Hi,
>>
>> To ensure a permanent IP we have a haproxy instance feeding AWS ELB to
>> a number of apache instances.
>>
>> All of the vhosts are pinned to www.somedomain.com rather than
>> somedomain.com, though we have dns setup so that the endpoiont for
>> each domain and www.domain is the haproxy box.
>>
>> What we need to do is redirect any traffic for somedomain.com to
>> www.somedomain.com.
>>
>> I have tried a number of different ways with the haproxy frontend
>> config but cannot get it to work consistently (that would be my
>> failure not haproxys).
>>
>> This is the nearest I have got:
>>
>> frontend:
>> acl www_hdr hdr_beg(host) -i www.
>> reqirep ^Host:\ (.*)$ Host:\ www.\1 if !www_hdr
>> redirect prefix / code 301 if !www_hdr
>>
>> If I then telnet to the haproxy I can see that the host line gets
>> rewritten correctly but I still get a 200 response not the expected
>> 301.
>>
>> Can anyone nudge me in the right direction please.
>>
>> regards
>>
>> Chris Allison
>>
>



-- 
Dingo: You must spank her well, and after you are done with her, you
may deal with her as you like... and then... spank me.
All: And me. And me too. And me.
Dingo: Yes. Yes, you must give us all a good spanking.
Dingo: And after the spanking, the oral sex.
Galahad: Well, I could stay a bit longer...

Monty Python And The Holy Grail.

Reply via email to