Forum Discussion

Philip_IT_71995's avatar
Philip_IT_71995
Icon for Nimbostratus rankNimbostratus
Jun 28, 2012

Redirect URL path to maintenance pool

I have an irule display problem (below iRule) for redirecting URL path to maintenance page's pool.

 

 

The request is that LTM need to redirect the URL path www.server.com/News/ to Maintenance page. The other URL path route to default pool. www.server.com/News/* to Maintenance page. www.server.com/* to Normal server page (default pool)

 

 

The result was that the “News” client can be redirected to maintenance pool for showing the content of index.html page but all images and web styles are missed. If I changed the default pool to maintenance pool, the maintenance page can display images and web styles properly.

 

 

Can someone help me to solve the irule problem?

 

 

=========

 

iRule Name: Redirect News URL to Maintenance only

 

 

when HTTP_REQUEST {

 

irule for when we are using News

 

if { [string tolower [HTTP::uri]] contains "/News/" }

 

{ log local0. "client [IP::client_addr] requested /News/ page"

 

log local0. "client [IP::client_addr] redirecting"

 

if { [TCP::local_port] == 443 }

 

{ HTTP::redirect "http://[getfield [HTTP::host] ":" 1 ][HTTP::uri]" }

 

HTTP::uri "/index.html"

 

pool "Pool_Maint"

 

}

 

 

===Maintenance Pool===

 

Name: Pool_Maint

 

Member==> 10.10.10.2:9088

 

Page=> Index.html

 

 

===Default Pool===

 

Name: Pool_Server_http

 

Member ==> 10.10.10.1:80

 

Name: Pool_Server_https

 

Member ==> 10.10.10.1:443
  • As soon as the HTTP::redirect line is hit, the irule stops processing, so you never actually get to the pool statement. The client has been redirected away from this HTTP_REQUEST session. You should probably just get rid of that line and change their URI accordingly.
  • can you try something like this? will it make any change?

    [root@ve1024:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       if { [HTTP::uri] starts_with "/News/" } {
          HTTP::uri "[string map {/News/ /} [HTTP::uri]]"
          pool "Pool_Maint"
       }
    }
    }
    
  • Thanks for your kind reply.

     

     

    I used "HTTP::redirect" as redirection of HTTPS to HTTP port.

     

     

    I also failed to get the images and style when redirect to pool_maint directly. (As above example)

     

     

    Btw, I need to redirect all url contains "/News/" to maintenance page of maintenance pool where there is no "/News/" url path.

     

    So I added the rewrite action (HTTP::uri "/index.html").

     

     

  • I also failed to get the images and style when redirect to pool_maint directly. (As above example) may i know what the image url is e.g. in view source menu in browser?
  • so, url for image could be /News/images/logo.gif, shouldn't it?

    the above irule should translate it to /images/logo.gif when sending to pool Pool_Maint.

    [root@ve1024:Active] config  b virtual bar list
    virtual bar {
       snat automap
       pool foo
       destination 172.28.19.79:80
       ip protocol 6
       rules myrule
       profiles {
          http {}
          tcp {}
       }
    }
    [root@ve1024:Active] config  b pool Pool_Maint list
    pool Pool_Maint {
       members 200.200.200.101:80 {}
    }
    [root@ve1024:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       if { [HTTP::uri] starts_with "/News/" } {
          HTTP::uri "[string map {/News/ /} [HTTP::uri]]"
          pool Pool_Maint
       }
    }
    }
    
    [root@ve1024:Active] config  ssldump -Aed -nni 0.0 port 80
    New TCP connection 1: 172.28.19.251(35181) <-> 172.28.19.79(80)
    1340963247.2490 (0.0011)  C>S
    ---------------------------------------------------------------
    HEAD /News/images/logo.gif HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Host: 172.28.19.79
    Accept: */*
    
    ---------------------------------------------------------------
    
    New TCP connection 2: 200.200.200.10(35181) <-> 200.200.200.101(80)
    1340963247.2500 (0.0007)  C>S
    ---------------------------------------------------------------
    HEAD /images/logo.gif HTTP/1.1
    User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
    Host: 172.28.19.79
    Accept: */*
    
    ---------------------------------------------------------------