Forum Discussion

BlackCisco_1037's avatar
BlackCisco_1037
Icon for Nimbostratus rankNimbostratus
Aug 15, 2007

Extend domain name that connects to Irule

Hi,

 

 

I am reading this forum frequently and got a lot of use full information from it and finally i can ask something.

 

 

 

I have wrote an irule and evrytime it is used it is redirected to the index.php. For example www.blockmeblockmeblockme.com/images/1.jpg ends up on our Apache box as a request to index.php

 

 

The problem we have with this is we cannot log the entire request (just the domain part) because we don’t know what file was originally requested.

 

 

Would it be possible to change the loadbalancer configuration so the original requested file (in the example above /images/1.jpg) will be part of the request on the Apache box?

 

 

Gr BlackCisco

 

9 Replies

  • Post your rule and I'm sure someone will be able to help you out.
  • You can probably include the original URI as a parameter to the page, something like:

     

     

    HTTP::redirect "http://www.host.com/index.jsp?uri=[HTTP::uri]"
  • Hi,

     

     

    Here is the ruke i created:

     

     

    when HTTP_REQUEST {

     

    set newUri /virtual/upcnl2a/stoppage/

     

    set newUri1 /images/logo.jpg

     

    set newUri2 /images/stop.gif

     

    set newUri3 /images/flageng.gif

     

    set newUri4 /css/style.css

     

    log local0. "Block"

     

    if { not ( [HTTP::uri] contains $newUri ) and not ( [HTTP::uri] contains $newUri1 ) and not ( [HTTP::uri] contains $newUri2 ) and not ( [HTTP::uri] contains $newUri3 ) and not ( [HTTP::uri] contains $newUri4 ) } {

     

    HTTP::uri $newUri

     

    }

     

    elseif { [HTTP::uri] contains $newUri1 } {

     

    HTTP::uri $newUri$newUri1

     

    } elseif { [HTTP::uri] contains $newUri2 } {

     

    HTTP::uri $newUri$newUri2

     

    } elseif { [HTTP::uri] contains $newUri3 } {

     

    HTTP::uri $newUri$newUri3

     

    } elseif { [HTTP::uri] contains $newUri4 } {

     

    HTTP::uri $newUri$newUri4

     

    }

     

    }

     

     

    Hope you can help.

     

     

    gr
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    When I break down your rule logic, it looks like all you are trying to do is re-write the URI to prepend the document root path if it hasn't already been.

    If so, try this:
    
    when RULE_INIT {
      set ::DocRoot /virtual/upcnl2a/stoppage/
    }
    when HTTP_REQUEST {
      if { !([string tolower [HTTP::uri]] contains $::DocRoot)}{
        HTTP::uri $::DocRoot[HTTP::uri]
      }
    }

    Otherwise let me know what I'm missing & we can try to help further.

    /deb
  • Hi everyone,

     

    Thanx for you're replies i'am now testing if it works.

     

     

    i will let you now

     

  • Deb,

     

     

    Can you explain to me how the rule works that you wrote cause our f5 guy just got fired and now every one looks to me as the f5 man.
  • Helllo,

     

     

    I should of explained the story/requirement a little more and still really really value your help - please. We currently have an Irule as below and we need to add one additional function. This function is that all requests made by the F5 Loadblancer that go to the web server using ony the following URL only:

     

     

    www.blackcisco.com/images/1.jpg ( and not to www.blackcisco.com/index.php - which it seem to do by default!)

     

     

    Current IRule: ( this rule determine what gif are set)

     

     

    when HTTP_REQUEST {

     

    set newUri /virtual/upcnl2a/stoppage/

     

    set newUri1 /images/logo.jpg

     

    set newUri2 /images/stop.gif

     

    set newUri3 /images/flageng.gif

     

    set newUri4 /css/style.css

     

    log local0. "BlackCisco"

     

    if { not ( [HTTP::uri] contains $newUri ) and not ( [HTTP::uri] contains $newUri1 ) and not ( [HTTP::uri] contains $newUri2 ) and not ( [HTTP::uri] contains $newUri3 ) and not ( [HTTP::uri] contains $newUri4 ) } {

     

    HTTP::uri $newUri

     

    }

     

    elseif { [HTTP::uri] contains $newUri1 } {

     

    HTTP::uri $newUri$newUri1

     

    } elseif { [HTTP::uri] contains $newUri2 } {

     

    HTTP::uri $newUri$newUri2

     

    } elseif { [HTTP::uri] contains $newUri3 } {

     

    HTTP::uri $newUri$newUri3

     

    } elseif { [HTTP::uri] contains $newUri4 } {

     

    HTTP::uri $newUri$newUri4

     

     

    Please could you save my life, and paste how the new Irule fuction (directing the URL) would fit with the current rule - thanks
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    It sounds like you are hitting a non-existent page, and your portal is displaying the default page instead of sending a 404/Not Found.

    With your iRule, here is what will happen:
    
    browser requestsserver will get request for
    ======================================================
    /images/logo.jpg/virtual/upcnl2a/stoppage/images/logo.jpg
    /images/stop.gif/virtual/upcnl2a/stoppage/images/stop.gif
    /css/style.css/virtual/upcnl2a/stoppage/css/style.css
    /images/flageng.gif/virtual/upcnl2a/stoppage/images/flageng.gif
    /images/1.jpg /virtual/upcnl2a/stoppage/
    /index.php/virtual/upcnl2a/stoppage/

    With my iRule, this is what will happen:
    
    browser requestsserver will get request for
    ======================================================
    /images/logo.jpg/virtual/upcnl2a/stoppage/images/logo.jpg
    /images/stop.gif/virtual/upcnl2a/stoppage/images/stop.gif
    /css/style.css/virtual/upcnl2a/stoppage/css/style.css
    /images/flageng.gif/virtual/upcnl2a/stoppage/images/flageng.gif
    /images/1.jpg /virtual/upcnl2a/stoppage/images/1.jpg
    /index.php/virtual/upcnl2a/stoppage/index.php

    Is either one close to what you were looking for?

    /deb