Forum Discussion

simont_85038's avatar
simont_85038
Icon for Nimbostratus rankNimbostratus
Nov 14, 2018

HTTPS Health monitor to follow 302 Redirect

Hi

 

I would like to create a HTTPS health probe monitoring a site that has a 302 Redirect. Instead of matching the 302 Redirect I would like to match the HTTP 200 OK response code from the redirected page. Is this possible and how would the monitor look like?

 

Thanks Simon

 

2 Replies

  • You could do this with an external monitor and use cURL to follow the redirect. This is an edited version of the sample monitor (/config/monitors/sample_monitor) The section you need to edit for your environment is:

    curl -L -H host:your.host.com https://$node_ip:$2/testpath | grep -E -i "200 OK" > /dev/null

    Please note this is untested

    !/bin/sh
    
    
     (c) Copyright 1996-2006, 2010-2013 F5 Networks, Inc.
    
     This software is confidential and may contain trade secrets that are the
     property of F5 Networks, Inc.  No part of the software may be disclosed
     to other parties without the express written consent of F5 Networks, Inc.
     It is against the law to copy the software.  No part of the software may
     be reproduced, transmitted, or distributed in any form or by any means,
     electronic or mechanical, including photocopying, recording, or information
     storage and retrieval systems, for any purpose without the express written
     permission of F5 Networks, Inc.  Our services are only available for legal
     users of the program, for instance in the event that we extend our services
     by offering the updating of files via the Internet.
    
     @() $Id: //depot/maint/bigip12.1.2-hf1/tm_daemon/monitors/sample_monitor1 $
    
    
    
    
     these arguments supplied automatically for all external pingers:
     $1 = IP (::ffff:nnn.nnn.nnn.nnn notation or hostname)
     $2 = port (decimal, host byte order)
     $3 and higher = additional arguments
    
     $MONITOR_NAME = name of the monitor
    
     In this sample script, $3 is the regular expression
    
    
     Name of the pidfile
    pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"
    
     Send signal to the process group to kill our former self and any children
     as external monitors are run with SIGHUP blocked
    if [ -f $pidfile ]
    then
       kill -9 -`cat $pidfile` > /dev/null 2>&1
    fi
    
    echo "$$" > $pidfile
    
     Remove the IPv6/IPv4 compatibility prefix
    node_ip=`echo $1 | sed 's/::ffff://'`
    
     Using the nc utility to get data from the server.
     Search the data received for the expected expression.
    curl -L -H host:your.host.com https://$node_ip:$2/testpath | grep -E -i "200 OK" > /dev/null
    
    status=$?
    if [ $status -eq 0 ]
    then
     Remove the pidfile before the script echoes anything to stdout and is killed by bigd
        rm -f $pidfile
        echo "up"
    fi
    
     Remove the pidfile before the script ends
    rm -f $pidfile
    
  • Hi,

    Why do you want the monitor to follow the 302 redirect???

    If the actual monitor is configured to request / with following send string:

    GET / HTTP/1.1\r\nHost: www.company.com\r\nConnection: close\r\n\r\n
    

    Why don't you get the 302 location header (ex: /newpath/index.html) and create the new send string with this URI:

    GET /newpath/index.html HTTP/1.1\r\nHost: www.company.com\r\nConnection: close\r\n\r\n