Forum Discussion

Patrick_Olsen's avatar
Patrick_Olsen
Icon for Nimbostratus rankNimbostratus
Nov 11, 2011

Tomcat

I'm new to iRules and have been doing some research here. I have tried multiple redirect scenarios and they all seem to fail.

 

 

Current try looks like this:

 

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "blah/manager/status" and [string tolower [HTTP::uri]] eq "/" } { HTTP::redirect } }

 

 

What am I missing?

 

 

Thanks!
  • What am I missing?

    if { [string tolower [HTTP::host]] eq "blah/manager/status"

    this will never be true, as the host would be something like www.domain.com

    Please try this:

    when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq "www.domain.com" and [string tolower [HTTP::uri]] eq "blah/manager/statusblah/manager/status" } { HTTP::redirect http://www.blah.com[HTTP::uri] } }

    Regards

    Kurt Knochner

  • just in case if you have not seen this.

     

     

    5-Minute iRules: What’s a URL?

     

    http://devcentral.f5.com/weblogs/jason/archive/2010/09/29/5-minute-irules-whatrsquos-a-url.aspx
  • many thanks to both of you. I have not seen the 5-Minute iRules and Kurt thank you.
  • Unfortunately Kurt your suggestion didn't appear to work. I'm basically trying to make it so that whenever anyone requests the tomcat manager page it redirects them to the main host URL. Anyone have a good idea for this?
  • can you try this?

    [root@ve1023:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.65.152:http
       ip protocol tcp
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1023:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
            if {[string tolower [HTTP::host]] equals "blah" and [string tolower [HTTP::uri]] equals "/manager/status"} {
                    HTTP::redirect "http://blah"
            }
    }
    }
    [root@ve1023:Active] config  curl -I http://blah/manager/status
    HTTP/1.0 302 Found
    Location: http://blah
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    
  • Hi nitass,

     

     

    I'm a bit confused as to why you would setup a SNAT and the portion after the rule myrule with the curl -I, I have never seen any of that used. Could you explain it a bit to me so that I can better understand it?

     

     

    Thanks again for your time.
  • Hi Patrick,

     

     

    I believe that nitass was just showing you the entire example of the Virtual Server that he used to apply the test iRule to, the test iRule itself, and then a successful test of the iRule using curl.

     

     

    curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP,

     

    SCP, SFTP, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.

     

     

    The -I option Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on a FTP or FILE file, curl displays

     

    the file size and last modification time only.

     

     

    You can find out more about curl here: curl

     

     

    Hope this helps.