Forum Discussion
Return a page when a port is accessed
Hi,
I want to create an iRule that if a specific port is accessed, it will return a page like "You used port 143, please use 8080".
when CLIENT_ACCEPTED {
if { [TCP::local_port] == 143 } {
HTTP::respond 200 content { Test You used port 143, please use 8080. } }
}
Thanks Much much!
2 Replies
- Lucas_Thompson_Historic F5 Account
You're 99% there. Just have to remember that you're not in HTTP yet. CLIENT_ACCEPTED happens in TCP, so you have to use TCP::respond instead of HTTP::respond. You can also send a response and close the connection before the client has actually transmitted the request, it's tolerated OK. For example:
TCP::respond "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\nPlease connect to port 8080 instead of port [TCP::local_port]"
- Stanislas_Piro2
Cumulonimbus
Hi,
If the VS is defined with * service port, create another VS with port 143 and profile HTTP.
enable the following irule on this VS:
when HTTP_REQUEST { HTTP::respond 200 content " You used port 143, please use 8080." }
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