All urls which are not like _https://uat.kamlesh.com/alfresco/api should not work

Hello, We have created VIp for url - https://uat.kamlesh.com/alfresco/api/ and client wants that he must be able to reach this url -https://uat.kamlesh.com/alfresco/api/ and if anyone trying to access with anything else must be rejected.

In fact all urls which are not like _https://uat.kamlesh.com/alfresco/api should not work.I need IRULE for the same. Please anyone could help in this.It would be very helpful.Thanks in advance.

Regards Kamlesh Y

if I understand you want to create a whitelist, to allow just a specific URL. If it is the cas this irule can help you:

when HTTP_REQUEST {

set uri [string tolower [HTTP::uri]]

if { $uri equals "/alfresco/api/ || $uri equals “/alfresco/api” }{

log loca0. “allow access”

} else {

log loca0. “Access denied for the following uri: $uri”

reject

}

}

Regards

Hello,

Try this one :

when HTTP_REQUEST {
  if { ! ([HTTP::host] equals "uat.kamlesh.com" and [HTTP::path] starts_with "/alfresco/api") } {
    reject
     alternative : HTTP::respond 403 content "request not authorized"
  }
}

corrected and functional irule:

when HTTP_REQUEST {

set uri [string tolower [HTTP::uri]]

if { $uri equals “/alfresco/api/” || $uri equals “/alfresco/api” } {

log local0. "allow access"

} else {

log local0. "Access denied for the following uri: $uri"

reject

}

}