Forum Discussion

kgaigl's avatar
kgaigl
Icon for Cirrocumulus rankCirrocumulus
Aug 14, 2019

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&uuml;r Sie da!</h1>
        <div>
        <p>Bitte entschuldigen Sie die Unannehmlichkeiten, aber wir f&uuml;hren auf dieser Seite gerade Wartungsarbeiten durch.</p>
        <p>Sie k&ouml;nnen uns jederzeit <a href="mailto:IV-ServiceDesk@versorgungskammer.de">kontaktieren</a>, wir sind aber in K&uuml;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

6 Replies

  • 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&uuml;r Sie da!</h1>
                            <div>
                            <p>Bitte entschuldigen Sie die Unannehmlichkeiten, aber wir f&uuml;hren auf dieser Seite gerade Wartungsarbeiten durch.</p>
                            <p>Sie k&ouml;nnen uns jederzeit <a href="mailto:IV-ServiceDesk@versorgungskammer.de">kontaktieren</a>, wir sind aber in K&uuml;rze wieder online.</p>
                            <p>Ihre Informationsverarbeitung</p>
                            </div>
                            </article>
                        }
                    }
                }
            }
        }
    }
  • kgaigl's avatar
    kgaigl
    Icon for Cirrocumulus rankCirrocumulus

    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's avatar
      Lee_Sutcliffe
      Icon for Nacreous rankNacreous

      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's avatar
    kgaigl
    Icon for Cirrocumulus rankCirrocumulus

    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's avatar
      Lee_Sutcliffe
      Icon for Nacreous rankNacreous

      I've corrected it in the comment above - (doesn't help replying on my phone!)

  • kgaigl's avatar
    kgaigl
    Icon for Cirrocumulus rankCirrocumulus

    ok, nad another error, with this:

    if {!([class match [IP::remote_addr] equals private_net])} {

    it works, many many thanks,