Forum Discussion
Darrell_Walker_
Nimbostratus
Jan 04, 2006Redirect based on port number
I'm looking for an irule that can do redirects based on certain port numbers.
For example:
http://server.domain.com:8888
to be redirected to:
https://server2.domain.com:8888
every other port to:
https://server3.domain.com
The actual code I'm toying with looks like:
when HTTP_REQUEST {
if {[IP::client_port] = 8888} {
HTTP::redirect https://[HTTP::host][HTTP::uri]:8888
}
else {
HTTP::redirect https://[HTTP::host][HTTP::uri]
}
}
- I see several problems with your code
when HTTP::REQUEST { log local0. "routing host [HTTP::host] and port [TCP::server_port]" if { ([TCP::local_port] == 8888) && ([HTTP::host] != "server2.domain.com") } { log local0. "Redirecting to https://server2.domain.com:8888[HTTP::uri]" HTTP::redirect https://server2.domain.com:8888[HTTP::uri] } elseif { ([TCP::local_port] != 443) || ([HTTP::host] != "server3.domain.com") } { log local0. "Redirecting to https://server3.domain.com[HTTP::uri]" HTTP::redirect https://server3.domain.com[HTTP::uri] } }
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