Search code examples
url-rewritingreverse-proxyhaproxywhitelistblacklist

can you whitelist urls with haproxy?


Hello I want to white list certain urls in haproxy such as

Only foobar.com/mypages/* can be accessible.

Anything else under foobar.com should be blocked.

Does haproxy give you the capability to do that?

Thanks, Bob


Solution

  • You can try the following configuration to get the desired result :

    #Will set the ACL if path matches
    acl allowed_url path_reg */mypages/*
    
    #Based on the previouslt set ACL , we can reject or allow connections
    #Accept/whitelist if matches
    tcp_request connection accept if allowed_url
    #Reject if not
    tcp_request connection reject if !allowed_url
    

    There are other path matching ACL directives: Path-directives.Use the one which suits your case best.