Jay Taylor's notes

back to listing index

Match regex/wildcard against http header NAMES in haproxy - Stack Overflow

[web search]
Original source (stackoverflow.com)
Tags: regular-expressions configuration haproxy howto stackoverflow.com
Clipped on: 2024-07-29

The 2024 Developer Survey results are live! See the results
    1. Home
    2. Questions
    3. Staging Ground
    4. Tags
    5. Saves
    6. Users
    7. Companies
    8. Labs
    9. Jobs
    10. Discussions
    11. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Now available on Stack Overflow for Teams! AI features where you work: search, IDE, and chat.

    Learn more Explore Teams
  2. Looking for

Asked 5 years, 11 months ago
Viewed 1k times
2

I'd like to add an acl rule to capture the existence of a header name that matches the following regex: ^X-w+-Signature (or whatever wildcard). Examples to match:

X-Abc-Signature
X-Whatever-Signature
X-Service-Signature

I know I could explicitly create rules like:

acl has_abc_token req.fhdr(X-Abc-Signature) -m found
acl has_whatever_token req.fhdr(X-Whatever-Signature) -m found
acl has_service_token req.fhdr(X-Service-Signature) -m found

Is it even possible to do this in haproxy?

Also, it's my understanding is that the w character class does not exist in haproxy?

It looks like req.hdr_names() might be what I'm looking for, but I'm at a loss at how to use it.

asked Aug 3, 2018 at 20:29
David Budiac
82122 gold badges99 silver badges2222 bronze badges

1 Answer

Sorted by:
1

Nevermind. I figured it out:

acl has_sig req.hdr_names() -m reg -i ,X-[A-Za-z]+-Signature
answered Aug 3, 2018 at 20:49
David Budiac
82122 gold badges99 silver badges2222 bronze badges

Your Answer

Community wiki

Not the answer you're looking for? Browse other questions tagged or ask your own question.