Forum Discussion

AlexB18's avatar
AlexB18
Icon for Nimbostratus rankNimbostratus
Sep 03, 2024

iRule not working for URI Block

I have a virtual server www.xyz.com hosted on LTM for HTTPS service
 
and i'm looking to block (403 response) one of the application URI which is https://www.xyz.com/MW/entryPoint.htm
 
I tried below irule but its not working .
 
when HTTP_REQUEST {
  if { [HTTP::has_responded] } { return }
  if  {[string tolower [HTTP::host]] contains "www.xyz.com" && [string tolower [HTTP::uri]] eq "/MW/entryPoint.htm" } {
HTTP::respond 403
    return
  }
}
 
Any suggestions appreciated. Thanks. 
  • You force the HTTP::uri to be lower case and compare it with a string with upper case letters. This can not work.

    This should work (not tested):

    when HTTP_REQUEST {
      if { [HTTP::has_responded] } { return }
      if  { ([string tolower [HTTP::host]] eq "www.xyz.com") && ([string tolower [HTTP::path]] eq "/mw/entrypoint.htm") } {
        HTTP::respond 403
      }
    }