Forum Discussion

SP_266134's avatar
SP_266134
Icon for Nimbostratus rankNimbostratus
Feb 28, 2019

Best way to redirect the traffic of request to protect admin modules in a site.

Problem: I have website has some admin modules exposed to public via site/admin. I want to bloc this request by the users, either send the request to another page that does not exist or redirect them to the home page of the site. What is best Irule or Stream modification. when HTTP_REQUEST { if { [string tolower [HTTP::host]] ends_with "website.com/Admin" } { HTTP::redirect "https://www.website.com[HTTP::uri]" } } or Is this the best way to do this in LTM.

 

Thanks for any pointer /guidance.

 

  • Hi SP,

    Create a data group with name admin-hosts and add your selected subnet of IPS in it. So anyone aside from this subnet will be redirected to the page you are configuring.

    when HTTP_REQUEST {
    if { ( [string tolower [HTTP::uri]] starts_with "/admin/" ) } {
        if { not ( [class match [IP::client_addr] equals admin-hosts] ) } {
            HTTP::redirect "https://www.website.com/"
            }           
        }       
    }
    
  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    If this is for security, then you should decode the URI before processing it, for "/" can be encoded.

     

    You may find this article "Fully Decode URI" useful if you want to pursue the route of the irule.

     

    Alternatively, you may want to explore the use of a traffic policy, which is preferable to the irule.