Forum Discussion

rkram_p's avatar
rkram_p
Icon for Altostratus rankAltostratus
Feb 23, 2026

Block specific URL's in APM

we have requirement to block particular URL's and URI.

can we block URL and URI in the APM provisioned F5 device.

 

Thanks,

RK

 

5 Replies

  • Yes you can, even with just LTM

    try something like this

    when HTTP_REQUEST
    {
        switch -glob [ string tolower [HTTP::uri] ]
        {
            "/uri1" -
            "/uri2"
            {
                drop
            }
            default
            {}
        }
    }

     

  • Hi rkram_p​

    if you really want to use APM, you could use Per-Request Polices. Do as Kostas said, use iRules instead.

    Cheers
    Daniel

    • you can try somthing like this

      when HTTP_REQUEST
      {
      	switch -glob [ string tolower [HTTP::host] ]
          {
              "test.example.com"
      		{
      			switch -glob [ string tolower [HTTP::uri] ]
      			{
      				"/uri1" -
      				"/uri2"
      				{
      					drop
      				}
      				default
      				{}
      			}
      		}
      		"test2.example.com"
      		{
      			switch -glob [ string tolower [HTTP::uri] ]
      			{
      				"/uri3" -
      				"/uri4"
      				{
      					drop
      				}
      				default
      				{}
      			}
      		}
      		default
      		{}	
          }
      }

       

  • You can also use Local Traffic Policy. I try to only use iRule if a Local Traffic Policy can not be effective.  Less CPU cost.

     

    GUI path: Local Traffic → Policies → Policy List → Create

    Use these settings:

    • Name: block_specific_url
    • Strategy: first-match (recommended for deterministic behavior)