Forum Discussion
ronniep_79067
Nimbostratus
Nov 13, 2009Help: Force to use DNS name
I have been looking for a while, but cannot locate any information. Is there a way one can use and irule to force a user to use dns as apposed to an IP address to connect to a server? Any help would be appreciated.
Thanks!
4 Replies
- ronniep_79067
Nimbostratus
I am currently using version 9. - hoolio
Cirrostratus
Hi Ronnie,
You could check the Host header value for at least one alpha character. If there isn't one, then redirect to a hardcoded hostname with the original URI:when HTTP_REQUEST { Check if host header value contains at least one alpha character if { not ([ string match -nocase "*\[a-z\]*" [HTTP::host] ])}{ Redirect client to the correct hostname, preserving the original URI HTTP::redirect "http://www.example.com[HTTP::uri] } }
Aaron - ronniep_79067
Nimbostratus
Thanks for your help, it will work for DNS requests as described. I guess I didn't explain very well.
We are trying to redirect all users using www.example.com to example.com. - hoolio
Cirrostratus
If you want to redirect a client that requests www.example.com to example.com, you could use an iRule like this:when HTTP_REQUEST { Check requested hostname (set to lower case) if {[string tolower [HTTP::host]] eq "www.example.com"}{ Redirect client to example.com with the same URI HTTP::redirect "http://example.com[HTTP::uri] } }
If this is for an HTTPS virtual server that both www.example.com and example.com resolve to, you would need to get a cert which is valid for example.com and www.example.com. You can get a 'Unified Communications Certificate' for this. Try searching these forums or the internet for details on this.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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