Hello Ricardo,

On Wed, 10 Jul 2019 at 15:38, Ricardo Fraile <rfra...@idealista.com> wrote:
>
> Hello,
>
>
> I have multiple backends and some of them share the same acl for the
> static content, as example:
>
>
> backend back-1
>     acl no-cookie path_end .gif .jpg .png (+15 more)
>     ignore-persist if no-cookie
>     ...
>
> backend back-2
>     acl no-cookie path_end .gif .jpg .png (+15 more)
>     ignore-persist if no-cookie
>     ...
>
>
> I try to look for a solution to define once the "acl no-cookie" but I
> can't find a workaround because it only works if I define it under the
> same backend.
>
> As middle step, I tried with env vars but it didn't work:
>
> global
>     setenv px-static .gif .jpg .png
>
> backend back-1
>     acl no-cookie path_end ${px-static}
>     ignore-persist if no-cookie

Two issues with your use of env vars:

- must be in double quotes
- must contain only alphanumerical characters and underscore

So I suggest
setenv pxstatic .gif .jpg .png

and
acl no-cookie path_end "$pxstatic"

Also read:
https://cbonte.github.io/haproxy-dconv/1.9/configuration.html#2.3


If you want to do more, you can set a txn variable in the frontend
(http-request set-var(txn.nocookie) 1 if no-cookie), based on your ACL
and use that variable in the backend (ignore-persist if {
var(txn.nocookie) 1 }).


cheers,
lukas

Reply via email to