Forum Discussion
Need a pointer
Hi I need some help with an irule that I am banging my head with. Basically I need to keep the uri intact from a client point of view and strip out the /development before it gets sent to the backend web server. Please see below which we have working
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
/development/ibi* {
Remove the /development prefix from the uri
HTTP::uri [string map {/development ""} [HTTP::uri]]
use node 1.1.1.1 80
log local0. "Host = [HTTP::host] URI = [HTTP::uri] "
}
/development/app* {
Remove the /development prefix from the uri
HTTP::uri [string map {/development ""} [HTTP::uri]]
use node 2.2.2.2 80
log local0. "Host = [HTTP::host] URI = [HTTP::uri])"
}
/development/* {
Remove the /development prefix from the uri
HTTP::uri [string map {/development ""} [HTTP::uri]]
use node 3.3.3.3 80
log local0. "Host = [HTTP::host] URI = [HTTP::uri])"
}
default {
Take some default action?
node 172.16.204.63 80
}
}
}
The problem I have is that one of the nodes sends a 302 back in the response and the URI contains something like /online/TestLogin.aspx. How do I get it to insert the /development before it goes back to the client i.e. /development/online/TestLogin.aspx so it remains totally transparent to the user?
Many Thank Craig
3 Replies
- nitass
Employee
e.g.[root@ve10: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@ve10:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set host [HTTP::host] HTTP::uri [string map {/development ""} [HTTP::uri]] } when HTTP_RESPONSE { if {[HTTP::is_redirect]} { HTTP::header replace Location [string map "http://${host}/ http://${host}/development/" [HTTP::header Location]] } } } [root@ve10:Active] config ssldump -Aed -nni 0.0 port 80 New TCP connection 1: 172.28.19.251(49146) <-> 172.28.19.79(80) 1349186691.3431 (0.0009) C>S --------------------------------------------------------------- HEAD /development/something 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 Accept: */* Host: www.abc.com --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(49146) <-> 200.200.200.101(80) 1349186691.3441 (0.0009) C>S --------------------------------------------------------------- HEAD /something 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 Accept: */* Host: www.abc.com --------------------------------------------------------------- 1349186691.3451 (0.0009) S>C --------------------------------------------------------------- HTTP/1.1 302 Found Date: Tue, 02 Oct 2012 14:21:04 GMT Server: Apache/2.2.3 (CentOS) Location: http://www.abc.com/online/TestLogin.aspx Connection: close Content-Type: text/html; charset=iso-8859-1 --------------------------------------------------------------- 1349186691.3451 (0.0020) S>C --------------------------------------------------------------- HTTP/1.1 302 Found Date: Tue, 02 Oct 2012 14:21:04 GMT Server: Apache/2.2.3 (CentOS) Location: http://www.abc.com/development/online/TestLogin.aspx Connection: close Content-Type: text/html; charset=iso-8859-1 --------------------------------------------------------------- - What_Lies_Bene1
Cirrostratus
This should do it but nitass's code is way better;
when HTTP_RESPONSE { if { [string tolower [HTTP::header]] values "Location" equals "/online/TestLogin.aspx" } { HTTP::header replace "Location" "/development/online/TestLogin.aspx" } } - craig_lee10_177
Nimbostratus
Thanks guys just had to do a few alterations in your suggestions and got it working, thanks for pointing me in the right direction
Craig
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
