Forum Discussion
Newbie mantenance page based on IP address
what i want to do for our maintenance page that redirects all except a certain IP address specified to a site down page.
so something like this only IP address 10.10.x.x , 142.x.x.x , 172.x.x.x are allowed to access the real site such as /prod/x
all other requests get sent to a redirection URL at /prod/maint/x
ive tried some examples it gets confusing for me when the IP addresses get thrown in.
Thanks alot.
- Chris_MillerAltostratusI like using data groups for this. You can configure an "address-type data group" from the GUI via "Local Traffic" -> "iRules" -> "Data Groups"
- Deekdeek_103899NimbostratusHi that sounds great, im running 9.4.8 if you could step by step it for me that would be great as i don't have a great understanding at this point.
- Chris_MillerAltostratusDid you create the datagroup yet? It's pretty self-explanatory once you get to the data groups section via my instructions above.
when HTTP_REQUEST { if { ![matchclass [IP::client_addr] eq maintenance_addresses] } { HTTP::redirect "http://www.sample.com/maintenancepage.html" } }
- Deekdeek_103899NimbostratusThanks for your quick responses, i will try this first thing in the AM and let you know how i fair out.
- Deekdeek_103899NimbostratusGreat stuff i made some little changes but this seems to work. Now i wanted to add 400,500 error redirects to this, should i incorporate into the same irule ? how would i include those?
when HTTP_REQUEST {
if { ![matchclass [IP::client_addr] eq M_Page] } {
if { not ([string tolower [HTTP::uri]] starts_with "/imageserver") } {
HTTP::redirect "https://xxx.xxxx.xxx/imageserver/ServiceUnavailable.html"
}
}
}
- Chris_MillerAltostratusYou can certainly add to the same iRule, yes. Are you basically trying to send the user to a specific page if LTM detects an error code response from a pool member?
- Deekdeek_103899Nimbostratusyes for instance if received 404, 403, 500 then again redirect to maintenance page.
- Chris_MillerAltostratusSimple enough, just use the "HTTP::status" command.
when HTTP_RESPONSE { switch -glob [HTTP::status] { "403" - "404" - "500" { HTTP::redirect "http://www.sample.com/maintenance.html" } } }
when HTTP_RESPONSE { switch -glob [HTTP::status] { "403" - "404" - "500" { HTTP::respond 302 Location "http://www.sample.com/maintenance.html" } } }
- Deekdeek_103899NimbostratusFirst one seems to work like a charm!
- hooleylistCirrostratusNice work, Chris.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com