Forum Discussion

Micka_61352's avatar
Micka_61352
Icon for Nimbostratus rankNimbostratus
Jul 21, 2011

Redirect traffic to root directory on server pool

 

Hi there,

 

 

 

Wondering if anyone can help. Will this iRule work. I want to be able to look at URL straing for data and send it to specific pool listening on port 81 once it hits this pool to have it look in the root forward. If these are not met send traffic to a different pool.

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with "/data/" } {

 

pool IESDWEB_HTTP_81} { "/"

 

} else {

 

pool IESDWEB_HTTP

 

}

 

}

 

 

 

Regards,

 

 

 

Michael.

 

6 Replies

  • Hi Michael,

    I don't believe this will work if I understand your question properly. Hopefully if I do I understand this properly you want to send traffic to pool IESDWEB_HTTP_81 if the URI starts with /DATA/ string, but then to direct them to URI "/" when you send them to the pool else send them to alternate pool.

    You could then rewrite this as

     when HTTP_REQUEST {    switch -glob [string tolower [HTTP::uri]]  {       "/data/*" {                     HTTP::uri "/"                     pool IESDWEB_HTTP_81                    }       default { pool IESDWEB_HTTP }     } } 

    I choose to use switch statement because in the grander scheme is more efficient then IF-ELSE statements when doing the same comparisons.

    I hope this helps

    Bhattman
  • Thank you for you comment.

     

     

    I have url for example http://test.test.com/data which I want to go to pool IESDWEB_HTTP_81 which is listening on port 81

     

     

    On the web server there is no data folder but instead a folder structure /:81/Account/LogOn

     

     

    So I would to have F5 check for string in URL /data/ but essentially redirect this to the http://test.test.com:81/Account/LogOn

     

     

    Does that make sense
  • Hi Michael,

    If you have port translation turned on then it's possible you don't need port 81 in the URL itself.

    In that case you can write it up as the following

    when HTTP_REQUEST {    switch -glob [string tolower [HTTP::uri]]  {       "/data/*" {                     HTTP::uri "/Account/LogOn"                     pool IESDWEB_HTTP_81                    }       default { pool IESDWEB_HTTP }     } }   

    However, incase you don't it could be written in the following manner

    when HTTP_REQUEST {    switch -glob [string tolower [HTTP::uri]]  {       "/data/*" {                     HTTP::uri ":81/Account/LogOn"                     pool IESDWEB_HTTP_81                    }       default { pool IESDWEB_HTTP }     } }  
    Note: I haven't tested this method out before so hopefully it works

    Bhattman
  • Hi Batmann

     

     

    Thanks for you comments but still have issue. Have some further detail about issue, uri starts with /DATA/ send to specific pool, the request should not be sent to Data folder(as this does not exist) but to redirect them to root folder on IIS folder structure on specific server with pool. If not matching this send to default pool.

     

     

    Regards,
  • Hi Bhattmann

     

    Thanks for you comments but still have issue. Have some further detail about issue, uri starts with /DATA/ send to specific pool, the request should not be sent to Data folder(as this does not exist) but to redirect them to root folder on IIS folder structure on specific server with pool. If not matching this send to default pool.

     

     

    Does this look right?

     

    when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/data/*" { HTTP::uri "/" pool IESDWEB_HTTP_81 } default { pool IESDWEB_HTTP } } }

     

    Or what would be the best way to handle this.

     

    Thanks

     

     

     

     

  • This iRule will remove the "/data" from your URI, but it will not replace the target document.

    So if your URL was:

    http://www.website.com/data/default.html

    This iRule should mask the "/data" from being sent to the server:

    Client Browser should show: http://www.website.com/data/default.html

    Request send to the Server will be: http://www.website.com/default.html

    If you need to modify the target document then you will want to make adjustments to this iRule.

    
    when HTTP_REQUEST {
    switch -glob [string tolower [HTTP::uri]] {
    "/data/*" {
    HTTP::uri [string map {"/data" ""} [string tolower [HTTP::uri]]]
    pool IESDWEB_HTTP_81
    }
    default { 
    pool IESDWEB_HTTP
    }
    }
    }
    

    Hope this helps, but if it is not let us know what behavior you still need adjusted.