How to automatically search for an invalid hostname (NXDOMAIN / dns_unresolved_hostname)

book

Article ID: 167704

calendar_today

Updated On:

Products

ProxySG Software - SGOS

Issue/Introduction

Mistyped and invalid domains present the user with a dns_unresolved_hostname exception, where the user will often subsequently search for it anyway.

Resolution

There are two elegant solutions to this which will provide the user with seamless search integration.

The first will automatically perform the search with the search engine specified in the code.

SSH to the SG, log in and type; -

en (press enter, and enter password)
conf t
exceptions
edit dns_unresolved_hostname
http-code 302
inline http format EOF
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.google.com/search?q=$(url.host)">
Redirecting you to <a href="http://www.google.com/search?q=$(url.host)">http://www.google.com/search?q=$(url.host)</a>
EOF
 

With any of these, it is easy to substitute in http://uk.search.yahoo.com/search?p= or www.bing.com/search?q= as desired.

This method, while effective, can leave the user wondering why they've been presented with search results, rather than the web page they asked for.

As an alternative to this, an exception page with an explanation and search links can be provided.

SSH to the SG, log in and type; -

en (press enter, and enter password)
conf t
exceptions
edit dns_unresolved_hostname
http-code 200
inline http format EOF
    $(url) could not be located, please use a link below to search with; -
        <br /><a href="http://www.google.com/search?q=$(url.host)">Google.com</a>
        <br /><a href="http://uk.search.yahoo.com/search?p=$(url.host)">Yahoo.com</a>
        <br /><a href="http://www.bing.com/search?q=$(url.host)">Bing.com</a>
        <br />or click <a href="$(url)">here</a> to try again.
EOF