Here is the scenario that I need some help with. I have a web site (https://my.web.com)that undergoes maintenance once a month and during that maintenance window, i would like regular users to go to a fallback page (i already have an irule for this and it works just fine), but the administrators working on the servers would like to test it before releasing it to the users. They come from a specific network, they need to be able to access the site while regular users go to the fallback page.
How can I automate it, is it possible or do i need to activate the iRule below during maintenance window.
when HTTP_REQUEST {
if { [IP::addr [IP::client_addr] equals 10.1.3.0/255.255.255.0] } {
HTTP::redirect “https://my.web.com/”
}
}
Thanks!
Here is our irule. We have the same issue, we want certain users to be able to access the site to test while everone else is sent to maintenance page, this irule checks for certian ip addresses and sends them to the site, everyone else, gets send to the maintenancne page. Hope you can use it.
when HTTP_REQUEST {
if { [IP::client_addr] starts_with "10." } {
if { [HTTP::uri] eq "/" and [HTTP::host] eq "your.url.com" } {
HTTP::redirect "http://your.url.com/wps/portal"
} elseif { [HTTP::uri] eq "/" and [HTTP::host] eq "your.url.com" } {
HTTP::redirect "https://your.url.com/wps/portal"
} else {
if { [IP::client_addr] eq "10.0.16.170" } {
use pool NG-loadtest1-pool
} elseif { [IP::client_addr] eq "10.0.16.175" } {
use pool NG-loadtest2-pool
} elseif { [IP::client_addr] eq "10.0.16.240" } {
use pool NG-loadtest3-pool
} else {
persist source_addr 255.255.255.255 1800
use pool new-fsc-pool
}
}
} else {
use pool nextgen-down
}
}
The first rule I think should have a negative condition to redirect everyone but the admin IP range, other that that looks fine:
when HTTP_REQUEST {
if {!([IP::addr [IP::client_addr] equals 10.1.3.0/255.255.255.0])}{
HTTP::redirect "https://my.web.com/"
}
}
lfowkes’ example is great for more specific requirements, but I do see a logic problem there: The redirect to https will never happen since the condition for the same condition is specified for the redirect to https immediately above it.
/deb
Hello, What’s the syntax to send the client to a pool instead of a url?
There is no way to directly send a client to a pool when performing an HTTP::redirect. You would just send them to a domain that resolved to an IP address of the intended destination VIP with the pool in question behind it.
Colin
Colin,
Thanks for responding so quickly. As you can see I am a newbie to IRULES. Can you help me with the following? I need to redirect 4 source IPs to a specific pool (pool has only 1 member)on a GTM.
What would be the best way of doing this?
Again, I have very little knowledge with syntax and rules.
Thanks - - -Jim
If all you’re looking to do is say “Source IP 1 goes to pool 1. Source IP 2 goes to pool 2” etc., then you’d want something like:
when CLIENT_ACCEPTED {
switch [IP::addr [IP::client_address]] {
10.10.10.10 { pool pool1 }
198.168.5.1 { pool pool2 }
216.46.42.118 { pool pool3 }
}
}
HTH,
Colin
Colin,
The GTM is complaining with the following message.
01070151:3: Rule [GOMEZ-REDIRECT-COLO] error:
line 1: [unknown event (CLIENT_ACCEPTED)] [when CLIENT_ACCEPTED {
switch [IP::addr [IP::client_address]] {
65.83.182.246 { pool Gomez_Intervalworld_External }
198.168.5.1 { pool Gomez_Intervalworld_External }
216.46.42.118 { pool Gomez_Intervalworld_External }
}
}]
iRules under GTM do not have the same events and methods as iRules under LTM. GTM iRules only know the events DNS_*
How do I write an iRule that would redirect the address http://www.abcd.com to https://portal.abcd1234.com/panet/? I have tried for hours to find this on DevCentral, please post any suggestions and thank you very much.
Here is an example
when HTTP_REQUESTS {
If {HTTP::host eq "www.abcd.com" } {
HTTP::redirect "https://portal.abcd1234.com/planet/?"
}
}