Hi Lukas,

this is great, didn't know that there is a shortcut for ACL written in
{...}. You're absolutely right that this is much more readable and also
I don't need those unique variable names holding the TRUE/FALSE state
for the ACL just for the next line. So, this is a perfect solution and I
can confirm that the redirect is performed straight away.

Just a small extra note for future reference of others: initially I
included all the redirects after the "use backend" instructions and when
I restarted HAProxy I got this warning:

[WARNING] 198/091249 (12592) : parsing [/var/proxy/haproxy.cfg:55] : a
'redirect' rule placed after a 'use_backend' rule will still be
processed before.

So, I moved the redirects to before the first "use backend" and all
works fine without any warning.


Thanks
Jürgen

Am 17.07.2013 21:02, schrieb Lukas Tribus:
> Hi Jürgen,
>
>
>> In our environment, we do have a lot of subdomains on various servers
>> and customers still tend to insert "www." in front of the domain name.
>> We would like to get rid of them by redirecting to the proper subdomain
>> without the leading www.
>> [...]
>>   acl condition1 hdr_dom(host) -i www.sub.domain1.com
>>   redirect prefix http://sub.domain1.com if condition1
>> [...]
>> Are there better ways of doing this?
> I would just transform them to one liners with an anonymous ACL, which is imo
> more readable than an dedicated ACL later referenced in redirect statement:
>   redirect prefix http://sub.domain1.com if { hdr_dom(host) -i 
> www.sub.domain1.com }
>
> It would be even nicer if we could do this with a single regexp instead of
> a per domain declaration, but I don't think thats currently possible.
>
>
>
>> Am I right, that the redirect isn't performed immediately and that
>> HAProxy goes through all subsequent declarations in that frontend before
>> closing the connection? If so, we could potentially end up with
>> double-matches, right?
> I don't think so. After the first "redirect" match, no other redirect
> statement should be processed.
>
> I cannot produce double matches even when trying.
>
>
>
>
> Regards,
>
> Lukas                                           


Reply via email to