Forum Discussion

Stephen_Winter's avatar
Stephen_Winter
Icon for Nimbostratus rankNimbostratus
Jan 24, 2008

Setting UserAgent for Monitoring?

Hi All,

 

 

I'm not real familiar with the internal working of http, but I'm trying to setup a monitor on some web server to check for content and it's failing because the server checks Browser version proir to allowing access.

 

 

If I put in "Unsupported Browser" in the validation text, it marks it as up, but unfortunately that's not enough to check..

 

 

Is there a way to change the User Agent on the LTM or to send a specific one in the Monitor config?

 

 

Thanks.

 

 

-Stephen
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi,

     

     

    You can specify the User-Agent header with a custom value in the send string of an HTTP or HTTPS monitor. This will work as an example for either:

     

     

    GET /path/to/file.ext HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11\r\nHost: \r\nConnection: close\r\n

     

     

    That all needs to be on one line in the send string field of the monitor. The receive string could be 200 OK.

     

     

    Aaron
  • Thanks for the quick response Hoolio.

     

     

    I still appear to be missing something. It doesn't seem to like the host portion. The error I'm getting is : "HTTP/1.1 requests require a Host: header" I am putting in "Host: myserver.mydomain.org" in the script you listed and changing the file to get. Everything else I left the same.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Is this what you have now?

     

     

    GET /path/to/file.ext HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11\r\nHost: myserver.mydomain.org\r\nConnection: close\r\n

     

     

    If so, that should work. Can you check the server access log to see what's being parsed as the request?

     

     

    Aaron
  • Here what I get from the command line.... I'll check with the server owner and see what he sees in the logs.

     

     

    Thanks.

     

     

     

    telnet 10.10.10.10 80

     

    Trying 10.10.10.10...

     

    Connected to 10.10.10.10.

     

    Escape character is '^]'.

     

    GET /default.asp HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11\r\nHost: myserver.mydomain.com\r\nConnection: close\r\n

     

     

    HTTP/1.1 400 Bad Request

     

    Server: Microsoft-IIS/5.0

     

    Date: Thu, 24 Jan 2008 22:21:12 GMT

     

    Connection: close

     

    Content-Type: text/html

     

    Content-Length: 124

     

     

    Host Header Required

     

    HTTP/1.1 requests require a Host: headerConnection closed by foreign host.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    telnet won't convert \r\n to carriage returns and line feeds, so that shouldn't work. If you want to use telnet to test, you can manually replace the \r\n's with the enter key.

     

     

    You can use echo with the -e flag to convert the characters. You can then pipe that output to netcat to open a TCP connection to the server and send the string:

     

     

    echo -e "GET /default.asp HTTP/1.1\r\nUser-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11\r\nHost: myserver.mydomain.com\r\nConnection: close\r\n" | netcat 10.10.10.10 80

     

     

    You should see the server's response in the netcat output.

     

     

     

    Aaron
  • Small hint instead of telnet and dealing with end of line chars You can use simple GET app from libwww-perl package (in Debian distro). It will make such tests easier:

     

     

    GET

     

    Usage: GET [-options] ...

     

    -m use method for the request (default is 'GET')

     

    -f make request even if GET believes method is illegal

     

    -b Use the specified URL as base

     

    -t Set timeout value

     

    -i Set the If-Modified-Since header on the request

     

    -c use this content-type for POST, PUT, CHECKIN

     

    -a Use text mode for content I/O

     

    -p use this as a proxy

     

    -P don't load proxy settings from environment

     

    -H send this HTTP header (you can specify several)

     

     

    -u Display method and URL before any response

     

    -U Display request headers (implies -u)

     

    -s Display response status code

     

    -S Display response status chain

     

    -e Display response headers

     

    -d Do not display content

     

    -o at> Process HTML content in various ways

     

     

    -v Show program version

     

    -h Print this message

     

     

    -x Extra debugging output

     

  • I did get it running properly withiin the LTM. I didn't realize that "telnet" would react differently.

     

     

    Thanks for all the help!

     

     

    -Stephen