Forum Discussion
tarma_58716
Nimbostratus
Jun 12, 2011split port url in the https class redirection
Hi i've a httpclass wich redirect the client to a new URL:
profile httpclass localhost_redirect {
defaults from httpclass
pool none
redirect "http://172.x.x.x:"2131"
}
The Vs has not a pool it just redirect the client to the new URL.
I would like to split the port number in to the browser.
Has anyone know how to write an irule allowing this.
I've tried to use this iRule but it doesn't work, the port still be displayed buy the Browser:
when HTTP_REQUEST {
if { [HTTP::header value Location] contains ":" } {
HTTP::header replace Location [lindex [split [HTTP::header value Location] ":"] 0]/
}
}
Thanks in advance for your help.
13 Replies
- nitass
Employee
let's say if the original url is 1.1.1.1:80 and the new url is 2.2.2.2:1234.
when user hits 1.1.1.1:80, what do u want?
do u want user gets content from 2.2.2.2:1234 but address bar still shows 1.1.1.1:80?
or something else? - tarma_58716
Nimbostratus
Hi nitass
when user hits 1.1.1.1:80 he is redirected to 2.2.2.2:1234, but i want the adress bar still shows 2.2.2.2 withou the port (1234).
After the redirection the user send all the requests to the new host:port. - nitass
Employee
not sure if it works if we set another virtual as 2.2.2.2:80 and send traffic to 2.2.2.2:1234. anyway, if i don't misunderstand, bigip has to directly connect to 2.2.2.2 subnet.
is it possible to test it out? - tarma_58716
Nimbostratus
i've 2VS: one is 1.1.1.1:80 and the other is 1.1.1.1:1234
The first VS do only redirection to the second and the requests should be sent to the second VS. - nitass
Employee
it seems to be different story. so, is this applicable?
virtual bar80 {
destination 172.28.17.88:80
ip protocol 6
rules myrule
profiles {
http {}
tcp {}
}
}
rule myrule {
when HTTP_REQUEST {
virtual bar1234
}
}
virtual bar1234 {
snat automap
pool foo
destination 172.28.17.88:1234
}
pool foo {
members 10.10.70.110:80 {}
}
curl -i http://172.28.17.88/
HTTP/1.1 200 OK
Date: Sun, 12 Jun 2011 04:53:09 GMT
Server: Apache/2.0.59 (rPath)
Last-Modified: Sat, 11 Jun 2011 00:31:47 GMT
ETag: "667a-67-cfb682c0"
Accept-Ranges: bytes
Content-Length: 103
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
... - tarma_58716
Nimbostratus
hi nitass thanks for your reply, it worked.
I've one more question, what should be the irule if i would like to redirect the request with a new URI.
For example, if the user hits 1.1.1.1:80, he is redirected http://new.host.redirect:1234/new_uri
ps:new.host.redirect should be 2.2.2.2
Thanks in advance - nitass
Employee
welcome and glad to hear that. :-)
do u mean something like this?
[root@tulip:Active] config b virtual bar80 list
virtual bar80 {
destination 172.28.17.88:http
ip protocol tcp
rules myrule
profiles {
http {}
tcp {}
}
}
[root@tulip:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if {[HTTP::uri] eq "/"} {
HTTP::redirect "http://new.host.redirect:1234/new_uri"
}
}
}
curl -I http://172.28.17.88/
HTTP/1.0 302 Found
Location: http://new.host.redirect:1234/new_uri
Server: BigIP
Connection: Keep-Alive
Content-Length: 0 - tarma_58716
Nimbostratus
Thank u very much for your help nitass.
Is it possible to hide the port number in the redirection on the client browser? - John_Alam_45640Historic F5 AccountTarma
It is possible that some browser allows hiding the port number. I never heard of one. It would totally be up to the browser configuration.
The best way to shield the user from a port number is the way that nitass described.
If the aim is to change the URI as well as the port number. Create a little irule for VIP2 and change the URI there:
rule irule_for_vip2 {
when HTTP_REQUEST {
if {[HTTP::uri] eq "/"} {
HTTP::uri "/new_uri"
}
}
} - nitass
Employee
i agree with john. i don't think it's possible to hide port number in http redirection.
by the way, why don't u send traffic to pool based on host header instead of redirection?
for example
[root@tulip:Active] config b virtual bar80 list
virtual bar80 {
destination 172.28.17.88:http
ip protocol tcp
rules myrule
profiles {
http {}
tcp {}
}
}
[root@tulip:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if {[HTTP::host] eq "old.host"} {
HTTP::redirect "http://new.host[HTTP::uri]"
} else {
snat automap
pool foo
}
}
}
curl -I http://old.host/test/
HTTP/1.0 302 Found
Location: http://new.host/test/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
curl -I http://new.host/test/
HTTP/1.1 200 OK
Date: Sun, 12 Jun 2011 14:51:55 GMT
Server: Apache/2.0.59 (rPath)
Last-Modified: Tue, 12 Oct 2010 19:17:25 GMT
ETag: "13094-51-53b1db40"
Accept-Ranges: bytes
Content-Length: 81
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
the old.host and new.host are mapped to the same vip i.e. 172.28.17.88.
cheer!
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
