Forum Discussion

tihi_341714's avatar
tihi_341714
Icon for Nimbostratus rankNimbostratus
Nov 06, 2018
Solved

Custom error page iRule with IP address filtering

Hi,

 

I'm not good with writing iRules so I would like some help. :)

 

We have a BIG-IP device with LTM and AFM provisioned. Customer would like us to configure the following. They have a list of public IP addresses that are allowed to reach/connect their server in our infra. They want to allow these addresses to access the server, but anything else besides these IPs should be redirected to a custom "underconstruction.html" page.

 

So I'm guessing the iRule would look like something like this:

 

if allowed ips try to access SERVER then forward traffic to POOL

 

else redirect to underconstruction.html

 

I'm bad at progamming, so this is all I got, I wouldn't know how to program this. :)

 

Or can this be done with LTM policies?

 

Any help is very much appriciated.

 

  • You can use LTM policy to achieve requirement.

    However iRule is also choice. Create data group

    MyIPList
    and try below iRule.

        when HTTP_REQUEST {
         if { [class match [IP::client_addr] equals MyIPList] } {
              pool alternate_pool
         } else {
              HTTP::redirect "https://[HTTP::host]/underconstruction.html"
            }
        } 
    

2 Replies

  • You can use LTM policy to achieve requirement.

    However iRule is also choice. Create data group

    MyIPList
    and try below iRule.

        when HTTP_REQUEST {
         if { [class match [IP::client_addr] equals MyIPList] } {
              pool alternate_pool
         } else {
              HTTP::redirect "https://[HTTP::host]/underconstruction.html"
            }
        } 
    
    • tihi_341714's avatar
      tihi_341714
      Icon for Nimbostratus rankNimbostratus

      Thanks a lot! I managed to get this working with an iFile.

       

      Have a nice day!