Re: CORS support

2019-12-17 Thread Alex Evonosky
Thank you Willy.  That did it!
Great work!



Sent from my Pixel 3XL


On Mon, Dec 16, 2019, 11:50 PM Willy Tarreau  wrote:

> Hello Alex,
>
> On Mon, Dec 16, 2019 at 01:22:42PM -0500, Alex Evonosky wrote:
> > Hello Haproxy group-
> >
> > migrating from haproxy 2.0 to 2.1 and noticed some directives changed:
> >
> > === 2.0.10 ===
> >
> > capture request header origin len 128
> > http-response add-header Access-Control-Allow-Origin
> %[capture.req.hdr(0)]
> > if { capture.req.hdr(0) -m end aiqwest.com }
> > http-response add-header Access-Control-Allow-Headers:\ Origin,\
> > X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m
> found }
> >
> >
> > === 2.1 ===
> >
> > capture request header origin len 128
> > http-response add-header Access-Control-Allow-Origin
> %[capture.req.hdr(0)]
> > if { capture.req.hdr(0) -m end aiqwest.com }
> > rspadd add-header Access-Control-Allow-Headers:\ Origin,\
> > X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m
> found }
> >
> >
> > getting:
> >
> > The 'rspadd' directive is not supported anymore since HAProxy 2.1. Use
> > 'http-response add-header' instead.
> >
> > when adding the said above, getting an error:
> >
> > 'http-response add-header' expects exactly 2 arguments.
>
> You almost had it right, actually it's exactly the same as in your
> first rule: first arg is the header name, second one is the value:
>
>http-response add-header Access-Control-Allow-Headers Origin,\
> X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m found }
>
> Please let us know if anything is not clear enough in the message or
> in the doc so that we can improve it.
>
> Willy
>


Re: CORS support

2019-12-16 Thread Willy Tarreau
Hello Alex,

On Mon, Dec 16, 2019 at 01:22:42PM -0500, Alex Evonosky wrote:
> Hello Haproxy group-
> 
> migrating from haproxy 2.0 to 2.1 and noticed some directives changed:
> 
> === 2.0.10 ===
> 
> capture request header origin len 128
> http-response add-header Access-Control-Allow-Origin %[capture.req.hdr(0)]
> if { capture.req.hdr(0) -m end aiqwest.com }
> http-response add-header Access-Control-Allow-Headers:\ Origin,\
> X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m found }
> 
> 
> === 2.1 ===
> 
> capture request header origin len 128
> http-response add-header Access-Control-Allow-Origin %[capture.req.hdr(0)]
> if { capture.req.hdr(0) -m end aiqwest.com }
> rspadd add-header Access-Control-Allow-Headers:\ Origin,\
> X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m found }
> 
> 
> getting:
> 
> The 'rspadd' directive is not supported anymore since HAProxy 2.1. Use
> 'http-response add-header' instead.
> 
> when adding the said above, getting an error:
> 
> 'http-response add-header' expects exactly 2 arguments.

You almost had it right, actually it's exactly the same as in your
first rule: first arg is the header name, second one is the value:

   http-response add-header Access-Control-Allow-Headers Origin,\ 
X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m found }

Please let us know if anything is not clear enough in the message or
in the doc so that we can improve it.

Willy



CORS support

2019-12-16 Thread Alex Evonosky
Hello Haproxy group-

migrating from haproxy 2.0 to 2.1 and noticed some directives changed:

=== 2.0.10 ===

capture request header origin len 128
http-response add-header Access-Control-Allow-Origin %[capture.req.hdr(0)]
if { capture.req.hdr(0) -m end aiqwest.com }
http-response add-header Access-Control-Allow-Headers:\ Origin,\
X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m found }


=== 2.1 ===

capture request header origin len 128
http-response add-header Access-Control-Allow-Origin %[capture.req.hdr(0)]
if { capture.req.hdr(0) -m end aiqwest.com }
rspadd add-header Access-Control-Allow-Headers:\ Origin,\
X-Requested-With,\ Content-Type,\ Accept if { capture.req.hdr(0) -m found }


getting:

The 'rspadd' directive is not supported anymore since HAProxy 2.1. Use
'http-response add-header' instead.

when adding the said above, getting an error:

'http-response add-header' expects exactly 2 arguments.


main question is, how can I convert the resadd statement to work with the
new 2.1?


Thank you!