Thanks :-)

Ok, I almost got it... The backend stuff and the errorfile trick is working, 
but I'm having a few problems with the content switching rule. So here's the 
backend stuff:
backend options                                                                 
                                                                                
                                                  
        server vm-host01 127.0.0.1:8081 maxconn 50 disabled                     
                                                                                
                                                   
        errorfile 503 /tmp/resp.txt

At first I tried this rule:
acl req_options                METH_OPTIONS   path_beg   /url1
use_backend options     if                   req_options

But that doesn't pass the configuration parser:
[ALERT] 095/124538 (2706) : parsing [/etc/haproxy.conf:41] : error detected 
while parsing ACL 'req_options'.
[ALERT] 095/124538 (2706) : parsing [/etc/haproxy.conf:56] : error detected 
while parsing switching rule.
[ALERT] 095/124538 (2706) : Error(s) found in configuration file : 
/etc/haproxy.conf
[ALERT] 095/124538 (2706) : Fatal errors found in configuration.

So then I tried:
acl req_options                path_beg   /url1  METH_OPTIONS
use_backend options     if                   req_options

And the parser sees no errors, but of course the METH_OPTIONS implicit AND 
isn't really working. How can get, in that same ACL rule, the OPTIONS method 
and the specific /url1 both matched?

Thanks so much.

Pedro.

On 05/04/2012, at 06:00, Baptiste wrote:

> Hey,
> 
> No need to apologies, sometimes it's faster to ask than looking for
> the solution for hours and building an ugly workaround.
> 
> If you need help for the setting up the solution, please let us know.
> 
> The content of the file may be:
> HTTP/1.0 200 OK
> Cache-Control: no-cache
> Connection: close
> Content-Type: text/html
> Access-Control-Allow-Origin: *
> Content-Length: < COUNT IT YOURSELF ;) >
> 
> ==> don't forget the empty line at the end of the file.
> 
> Despite using errorfile 503, haproxy would answer a 200 OK using the file 
> above.
> 
> cheers
> 
> 
> On Wed, Apr 4, 2012 at 11:52 PM, Pedro Mata-Mouros
> <[email protected]> wrote:
>> Hi,
>> 
>> I really should've thought of that for myself, sorry about that... :-)
>> 
>> Thanks so much, will try it tomorrow!
>> 
>> Pedro.
>> 
>> 
>> On 04/04/2012, at 21:01, Baptiste wrote:
>> 
>>> Hey,
>>> 
>>> This is doable using content switching to route your request to a
>>> backend where where no servers are up.
>>> In this backend, just use the statement "errorfile" to tell haproxy to
>>> load content of the response from a local file
>>> 
>>> You're done.
>>> 
>>> cheers
>>> 
>>> 
>>> On Wed, Apr 4, 2012 at 8:37 PM, Pedro Mata-Mouros
>>> <[email protected]> wrote:
>>>> Hi everyone, Willy,
>>>> 
>>>> Either I'm really unaware if HAProxy can do this or not, or I completely 
>>>> forgot it. Is it possible to check for a specific request and promptly 
>>>> return a user defined response, without the need to go to a backend?
>>>> 
>>>> I basically need to return an empty HTTP 200 with 
>>>> "Access-Control-Allow-Origin: *" whenever somebody sends me an "OPTIONS 
>>>> /url HTTP/1.1", and I don't want that to be processed by the application 
>>>> in the backend.
>>>> 
>>>> Thanks.
>>>> 
>>>> Pedro.
>>>> 
>>>> 
>>> 
>> 
>> 
> 


Reply via email to