2

I'm trying to build a reg exp for haproxy that will match the second URL and direct it to a different acl than the first:

mysite.com/path/
mysite.com/path/something_random

The issue is that my first reg exp matches both urls above when it should only match the second one. I can't find more documentation on haproxy regex's format either so I'm not even sure where to reference the reg exp format I should be using for matching. Can reg exp pro's help me I'm new to this thanks.

 acl filebrowser_route path_reg ^/path/.*
 acl filebrowser url_beg /path
Nimjox
  • 217
  • 1
  • 3
  • 14
  • It looks to me like both your ACLs will match both URLs. If the first URL is ONLY ever going to be `mysite.com/path/`, then the ACL should be `acl filebrowser path /path/` – GregL Oct 15 '15 at 17:10

1 Answers1

8

You need to construct two regex's that are mutually exclusive: only one can be true at a time:

How about if you make the second item be a regex like:

^/path[^/]

The [^/] means "any character that is not /".

Here are three URLs that are mutually exclusive:

acl fb1 path_reg ^/path$          # Just /path
acl fb2 path_reg ^/path/$         # Just /path/
acl fb3 path_reg ^/path/..*$      # /path/ plus at least 1 character
TomOnTime
  • 7,945
  • 6
  • 32
  • 52
  • Really great clear examples on the regex. Thanks this works. – Nimjox Oct 15 '15 at 17:55
  • I just see the answer from TomOnTime and follow it. I think the correct regex for "any character that is not /" should be: ^/path[^/] ^ but not ~ – thenewasker Jul 18 '18 at 09:59