Forum Discussion

Naumin_Dave_144's avatar
Naumin_Dave_144
Icon for Nimbostratus rankNimbostratus
Jan 27, 2015

Issue with http redirection in version 11.5.1(previously working with http class profiles in version 11.3)

Hi All,

 

we have some applications which need to be redirected to the servers meaning only works if uri is been added i.e. abc.com ---> abc.com/xyz/tmz/qpd.apex. So for that we used http class redirection profile in 11.3 version. Now in current scenario, we dont have http class profile in version 11.5.1. So i tried to use as following irule:

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] contains ".abc.com" } { HTTP::redirect "https://abc.com/xyz/tmz/qpd.apex [HTTP::uri]" pool Applivation_server } }

 

Issue: I am able to redirect to uri but in statistics see hit on VS, irule but no hit on Pool(Containing application servers) or Pool members(application servers).

 

Your reply on this been appreciated.

 

11 Replies

  • Hi Naumin Dave,

    without knowing the exact configuration of your v11.3 http-class profile I just try to make a good guess regarding the iRule equivalent:
    when HTTP_REQUEST { 
         test condition of matching hostname and client was not already redirected (default path)
        if { ([string tolower [HTTP::host]] ends_with "abc.com") && ([HTTP::uri] eq "/") } { 
             redirect client into https and required path
            HTTP::redirect https://abc.com/xyz/tmz/qpd.apex
            return
        } else {
             forward client request for redirected traffic on non default path
            pool Application_server 
        }
    } 
    

    Thanks, Stephan

  • Hi Stephan,

     

    So i tried to insert two statements in one if condition.

     

    1. For Redirection which redirects url.
    2. Send redirected url to pool.

    But it works only for 1'st statement(Redirection works) but is not forwarding traffic to Pool.

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Naumin Dave,

    Do you just require a rewrite? If so I've tailored Stephen's irule:

    when HTTP_REQUEST { 
         test condition of matching hostname and client was not already redirected (default path)
        if { ([string tolower [HTTP::host]] ends_with "abc.com") && ([HTTP::uri] eq "/") } { 
             rewrite URI to append /xyz/tmz/qpd.apex
            HTTP::uri "/xyz/tmz/qpd.apex"
            pool Application_server 
        }
    }
    

    Hope this helps,

    N

  • Do you see any errors in /var/log/ltm?

    tail -f /var/log/ltm

    Please be aware, that changes to your iRule will apply to new connections only.

    A browser will try to maintain keep-alive connections and changes will not be working on existing connections.

    So closing all browser windows will be mandatory.

    Or just test via "cURL" (please replace value of host header and path accordingly):

    curl -I -H "Host: abc.com" http:///xyz/tmz/qpd.apex

  • Hi Stephan,

     

    If i will try to access using virtual ip, i am able to access page (after applying your irule) but page without any background images. And in tail -f /var/log/ltm, i am not able to see any error.

     

    • StephanManthey's avatar
      StephanManthey
      Icon for MVP rankMVP
      Nathan´s approach rewrites all incoming requests with a single URI. Images will probably requested by specific URIs and are missing that´s why. Can you please provide the configuration of your v11.3 http-class?
  • Hi Stephan, Sorry small correction. I am able to access page (after applying Nathan's irule). Also http class configuration is as follow:

     

    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      what's the action in this http class? or can i assume it's set to none. in that case it would go to the VS default pool.
  • Hi,

    as an equivalent my iRule would look like this:
    when HTTP_REQUEST {
      if { ! ([string tolower [HTTP::uri] starts_with /snortreport-1.3.4/) } {
         HTTP::redirect "https://172.27.95.203/snortreport-1.3.4/"
      }
    }
    

    As your 2nd screenshot does not contain the full redirection path it might be necessary to modify the path in the iRule above.

    Thanks, Stephan
  • You can add a log statement to validate incoming requests or use a browser plugin (maybe your browser cache just needs to be cleared?):

    when HTTP_REQUEST {
      log local0. "request received <[HTTP::method]> <[HTTP::uri]> <[HTTP::version]>"
      if { ! ([string tolower [HTTP::uri] starts_with /snortreport-1.3.4/) } {
         HTTP::redirect "https://172.27.95.203/snortreport-1.3.4/"
      }
    }
    

    With the following command you can track new log messages:

    tail -f /var/log/ltm  
    

    PS: The iRule above requires to have a default pool assigned to the virtual server in the resource section.