Forum Discussion
dyobbs_25515
Feb 03, 2012Nimbostratus
iRule to redirect a variable to http
Guys hi,
I'm newbie here. I wanted to create an iRule, that truncates the later part of the message from the "http://.acme.com" to http://
any help is appreciated.
Will this work?
when HTTP_REQUEST {
if { [HTTP::uri] starts_with ".acme.com" } {
HTTP::redirect "http://[HTTP::host]"
}
- nitassEmployeee.g.
[root@ve1023:Active] config b virtual bar list virtual bar { snat automap pool Pool_Test_Sorry_Alfresco destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve1023:Active] config b pool Pool_Test_Sorry_Alfresco list pool Pool_Test_Sorry_Alfresco { monitor all http members 200.200.200.101:80 {} } [root@ve1023:Active] config b pool Pool_Test_Sorry_Alfresco|grep -i pool\ member +-> POOL MEMBER Pool_Test_Sorry_Alfresco/200.200.200.101:80 active,up [root@ve1023:Active] config curl -I http://172.28.19.79 HTTP/1.1 200 OK Date: Thu, 09 Feb 2012 15:25:01 GMT Server: Apache/2.2.3 (CentOS) Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT ETag: "4183e4-3e-9c564780" Accept-Ranges: bytes Content-Length: 62 Content-Type: text/html; charset=UTF-8 [root@ve1023:Active] config b pool Pool_Test_Sorry_Alfresco monitor all fake [root@ve1023:Active] config b pool Pool_Test_Sorry_Alfresco|grep -i pool\ member +-> POOL MEMBER Pool_Test_Sorry_Alfresco/200.200.200.101:80 inactive,down [root@ve1023:Active] config curl -I http://172.28.19.79 HTTP/1.0 302 Found Location: http://dev-sorry-webarch.xyz.com Server: BigIP Connection: Keep-Alive Content-Length: 0
- dyobbs_25515NimbostratusNitass hi,
- nitassEmployeeit is because header is different when requesting directly and using explicit proxy.
this is directly request. [root@ve1023:Active] config ssldump -Aed -nni 0.0 port 80 Feb 13 02:26:36 local/tmm notice tmm[4822]: 013e0001:5: Tcpdump starting bcast on :::0 from 127.1.1.1:34917 New TCP connection 1: 172.28.19.251(45151) <-> 172.28.19.79(80) 1329128801.9948 (0.0009) C>S --------------------------------------------------------------- HEAD /whatever 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.yahoo.com.acme.com.nz --------------------------------------------------------------- this is request with f5 as an explicit proxy. [root@ve1023:Active] config ssldump -Aed -nni 0.0 port 80 Feb 13 02:27:30 local/tmm notice tmm[4822]: 013e0001:5: Tcpdump starting bcast on :::0 from 127.1.1.1:57671 New TCP connection 1: 172.28.19.251(45152) <-> 172.28.19.79(80) 1329128868.8840 (0.0012) C>S --------------------------------------------------------------- HEAD http://www.yahoo.com.acme.com.nz/whatever 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: www.yahoo.com.acme.com.nz Pragma: no-cache Accept: */* Proxy-Connection: Keep-Alive --------------------------------------------------------------- this is an example irule when using f5 as an explicit proxy. [root@ve1023:Active] config b virtual bar list virtual bar { destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve1023:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set host [string tolower [HTTP::host]] set proxy_uri [string tolower [HTTP::uri]] set uri [getfield $proxy_uri $host 2] set newhost [string map {".acme.com.nz" ""} $host] if {$host ne $newhost} { HTTP::redirect "http://$newhost$uri" } } } [root@ve1023:Active] config curl -I http://www.yahoo.com.acme.com.nz/whatever -x 172.28.19.79:80 HTTP/1.0 302 Found Location: http://www.yahoo.com/whatever Server: BigIP Connection: Keep-Alive Content-Length: 0
- Kalpesh_48932NimbostratusHello Nitass..Thanks for this configuration..but can you give me config to be used in webconsole..not on command line...
- nitassEmployeehi Kalpesh,
- Kalpesh_48932Nimbostratus02/09/2012 03:21 PM
- Kalpesh_48932Nimbostratuse.g.
- nitassEmployeeHow to use it in web console....?oh sorry i just noticed i forgot to post the irule.
when HTTP_REQUEST { if {[active_members [LB::server pool]] < 1} { HTTP::redirect "http://dev-sorry-webarch.xyz.com" } }
- Kalpesh_48932NimbostratusThis is the rule I have..but I have to use HTTP_referrer in it..........., i would like to have as http_referrer (which is used for that : _http://en.wikipedia.org/wiki/HTTP_referer) wth the original DNS called
- dyobbs_25515NimbostratusNitass hi,
Recent Discussions
Related Content
Â
DevCentral Quicklinks
* 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
Discover DevCentral Connects