Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4736

How to block URLs that does not contain a specific word using HA proxy

$
0
0

I am trying to block URL’s that does not contain a word “Developer” in the URL’s query string urls.primaryName’s value.

URL’s to block:

  1. /swaggerui/PetStore/index.html?urls.primaryName=V1-Private
  2. /swaggerui/PetStore/index.html?urls.primaryName=V1-Internal

URL’s to allow:

  1. /swaggerui/PetStore/index.html?urls.primaryName=V1-Developer

Below is the configuration I have tried.

frontend http-in
    acl url_petstore_v2 path_beg -i /swaggerui/PetStore/

    use_backend petstore_v2 if url_petstore_v2


backend petstore_v2
    http-request deny if { path_reg /swaggerui/PetStore/index\.html\?urls\.primaryName=(?i)(?!.*Developer).* }

    server petstore1 $PS_HOST$SERVER_ADDRESS_TAIL:$PS_PORT check $TLS_APPEND $HAPROXY_RESOLVER_EXPR

Regex expression I have used does match the URL’s as you can see in this online regex test tool.

But this configuration is not blocking the URLs and allowing all the URLs.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4736

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>