Forum Discussion
IRule Maintenance Page only from outside
Hi,
I've got an IRule with a static Maint-Page:
when HTTP_REQUEST {
if { [active_members [LB::server pool]] < 1 } {
switch [HTTP::uri] {
"/mylogo.png" {HTTP::respond 200 content [ifile get "mylogo.png"]}
default {HTTP::respond 200 content {
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
<article>
<img src="/mylogo.png" />
<h1>Wir sind bald wieder für Sie da!</h1>
<div>
<p>Bitte entschuldigen Sie die Unannehmlichkeiten, aber wir führen auf dieser Seite gerade Wartungsarbeiten durch.</p>
<p>Sie können uns jederzeit <a href="mailto:IV-ServiceDesk@versorgungskammer.de">kontaktieren</a>, wir sind aber in Kürze wieder online.</p>
<p>Ihre Informationsverarbeitung</p>
</div>
</article>
}
}
}
}
}
now I need to bypass the Maintenance Page if the request comes from inside the organisation.
there's a data group list "private_net" I think I could use this with
if { ([class match [IP::client_addr] equals "private_net"]) }
but I'm not sure how to combine this,
could someone give me some help?
thanks a lot
- Lee_Sutcliffe
Nacreous
You can try this combination, it will not display the content if the source IP address is defined in your data group.
Notice the 'not' (!) in the if statement used in the default section of the switch.
when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1 } { switch [HTTP::uri] { "/mylogo.png" { HTTP::respond 200 content [ifile get "mylogo.png"] } default { if {!([class match [IP::addr [IP::client_addr]] equals "private_net"])} { HTTP::respond 200 content { <!doctype html> <title>Site Maintenance</title> <style> body { text-align: center; padding: 150px; } h1 { font-size: 50px; } body { font: 20px Helvetica, sans-serif; color: #333; } article { display: block; text-align: left; width: 650px; margin: 0 auto; } a { color: #dc8100; text-decoration: none; } a:hover { color: #333; text-decoration: none; } </style> <article> <img src="/mylogo.png" /> <h1>Wir sind bald wieder für Sie da!</h1> <div> <p>Bitte entschuldigen Sie die Unannehmlichkeiten, aber wir führen auf dieser Seite gerade Wartungsarbeiten durch.</p> <p>Sie können uns jederzeit <a href="mailto:IV-ServiceDesk@versorgungskammer.de">kontaktieren</a>, wir sind aber in Kürze wieder online.</p> <p>Ihre Informationsverarbeitung</p> </div> </article> } } } } } }
- kgaigl
Cirrocumulus
Hi Lee,
many many Thanks, but maybe there's some wrong braket, but I cant't figure out where:
01070151:3: Rule [/Common/MAINT_PAGE_ONLY_EXTERN] error: /Common/MAINT_PAGE_ONLY_EXTERN:8: error: ["unexpected end of arguments;expected argument spec:equals"][IP::addr [IP::client_addr]]
- Lee_Sutcliffe
Nacreous
Sorry, my mistake - there is a missing closing square bracket, try replacing the 'if' statement on line 8 with the following
if {!([class match [IP::addr [IP::client_addr]] equals "private_net"])} {
- kgaigl
Cirrocumulus
sorry but now I get the error ""wrong # of arguments"
01070151:3: Rule [/Common/MAINT_PAGE_ONLY_EXTERN] error: /Common/MAINT_PAGE_ONLY_EXTERN:8: error: ["wrong # of arguments"][class match [IP::addr [IP::client_addr] equals "private_net"]]
shame on me not to find the error myself
- Lee_Sutcliffe
Nacreous
I've corrected it in the comment above - (doesn't help replying on my phone!)
- kgaigl
Cirrocumulus
ok, nad another error, with this:
if {!([class match [IP::remote_addr] equals private_net])} {
it works, many many thanks,
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