Hello,

On Wed, 2019-07-10 at 16:09 +0200, Lukas Tribus wrote:
> 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://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcbonte.github.io%2Fhaproxy-dconv%2F1.9%2Fconfiguration.html%232.3&amp;data=02%7C01%7C%7Cc2d173a38dcf4f74c6f108d7054048e4%7Cd78b7929c2a34897ae9a7d8f8dc1a1cf%7C0%7C0%7C636983645968605647&amp;sdata=lCLgmDfHJRAbfW8q%2BEM6o%2BhsBsZzD6P53EVGdy7zFmo%3D&amp;reserved=0
> 
> 
> 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


Setting the suggested configuration doesn't work in v1.8, it looks like
setenv have a limit in the number of arguments:


global
    setenv pxstatic .gif .jpg .png

backend xx
    acl no-cookie path_end "$pxstatic"
    ignore-persist if no-cookie


# haproxy -c -f haproxy.cfg 
[ALERT] 191/092843 (85340) : parsing [haproxy.cfg:18] : 'setenv' cannot
handle unexpected argument '.png'.
[WARNING] 191/092843 (85340) : parsing acl keyword 'path_end' :
  no pattern to match against were provided, so this ACL will never
match.
  If this is what you intended, please add '--' to get rid of this
warning.
  If you intended to match only for existence, please use '-m found'.
  If you wanted to force an int to match as a bool, please use '-m
bool'.

[ALERT] 191/092843 (85340) : Error(s) found in configuration file :
haproxy.cfg
[ALERT] 191/092843 (85340) : Fatal errors found in configuration.

I tried to set the list under single and double quotes, the error
disappears but it didn't work. Using () and {} still had the error.
Setting only one extension works, two, only with the first on the list.

What is the right assignment to use in setenv?


The alternative configuration that Aleksandar pointed, it works, but I
prefer to have this small list under the main file.



Thanks for the info,


Reply via email to