Hi,

On Tue, Jan 10, 2012 at 11:52:33PM -0800, Ramin K wrote:
> I've got the follow config in testing which works.
> 
> frontend tester 10.13.200.53:80
>   acl url_7095 path_beg -i /7095
>   acl url_7096 path_beg -i /7096
>   acl url_7097 path_beg -i /7097
> 
>   use_backend vidserver_7095 if url_7095
>   use_backend vidserver_7096 if url_7096
>   use_backend vidserver_7097 if url_7097
> 
> backend vidserver_7095
>     reqirep ^([^\ ]*)\ /7095/(.*)    \1\ /2
>     server vidserver 127.0.0.1:7095 check
> and so on.
> 
>       The problem I'm trying to solve is to make a number of video servers 
> show up on port 80 to keep them from being blocked by poorly configured 
> corp firewalls. To that end I was hoping I could accept connections with 
> HAProxy, read the uri, and rewrite to localhost:port_based_on_uri on the 
> fly using a bit of regex. If it were just 3-4 per server I'd leave it as 
> above, but it's closer to 40 or so per server with the content system 
> scheduling to different servers based on concurrent servers. I could 
> ultimately just configure all possible iterations on each server, but 
> was hoping for a less brute force approach.
>       In any case going through the docs I think the following is the 
>       right path, but so far I haven't found anything that works or is a 
> large 
> syntax violation.

The only things I can think of is to simplify the regex to make the
number disappear as in the example below :

  backend vidserver_7095
    reqirep ^([^\ ]*)\ /[^/]*/(.*)    \1\ /2
    server vidserver 127.0.0.1:7095 check

and to use anonymous ACLs to have them on one line :

   use_backend vidserver_7095 if { path_beg /7095 }
   use_backend vidserver_7096 if { path_beg /7096 }
   use_backend vidserver_7097 if { path_beg /7097 }

But clearly if you want to map specific URL prefixes to specific servers,
at one point you need to establish this mapping and I don't see how to
simplify it further. Also I'd say that 40 lines is not *that* dramatic,
I've already seen multi-megabytes config files (real!). What's the most
important is that they follow a certain logic so that you limit the risk
of typos and human errors.

Regards,
Willy


Reply via email to