Forum Discussion

Cristian_Daniel's avatar
Cristian_Daniel
Icon for Nimbostratus rankNimbostratus
Dec 20, 2013

APM: change HTTP Response

I'm getting a "?" character on a response and I want to change it I'm using this:

when HTTP_RESPONSE {

set iRedirectResp [HTTP::header Location]
log local0. "$iRedirectResp this made match!"

if { [HTTP::header Location] contains "www.reaxis.com?" } {

    log local0. "the location made match on the IF"
    HTTP::respond 302 Location https://www.reaxis.com Server CompaniXServer 
}

}

Also I'm taking this logs:

Dec 20 08:01:51 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : The URL is www.companyx.co/biblos/imagenes/menu2_r1_c1.gif Dec 20 08:01:51 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : this made match! Dec 20 08:01:54 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : The URL is www.companyx.co/biblos/bases_datos/titulo_r.php? Dec 20 08:01:54 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : https://www.reaxys.com? this made match! Dec 20 08:01:55 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : The URL is www.reaxys.com? Dec 20 08:01:55 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : this made match!

8 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account

    What behavior is that you're seeing when you try to execute this iRule? I'm willing to bet you're having trouble with the HTTP::respond command in the context under which you're running. Are there any particular logs that show errors? The logs you've shown above just show that the match portion is working. What happens for the client?

     

    -Colin

     

  • The client receive the respond from the server with the location "https://www.reaxys.com?" Without quotes. That is invalid. Then I need to deliver to the client the response "https://www.reaxys.com"

     

  • Did you try to add quotes to your URL into your respond line ?

    HTTP::respond 302 Location "https://www.reaxis.com" Server CompaniXServer 
    

    Or you can try this ?

    set iRedirectResp [HTTP::header Location]
    log local0. "$iRedirectResp this made match!"
    
    if { [HTTP::header Location] contains "www.reaxis.com?" } {
        HTTP::header remove Location
        log local0. "the location made match on the IF"
        HTTP::respond 302 Location "https://www.reaxis.com" Server CompaniXServer 
    }
    
    • Cristian_Daniel's avatar
      Cristian_Daniel
      Icon for Nimbostratus rankNimbostratus
      Thank you for your response, I made the changes and doesn't work, I think that maybe I'm getting bad the event, because this is on a APM.
  • Did you try to add quotes to your URL into your respond line ?

    HTTP::respond 302 Location "https://www.reaxis.com" Server CompaniXServer 
    

    Or you can try this ?

    set iRedirectResp [HTTP::header Location]
    log local0. "$iRedirectResp this made match!"
    
    if { [HTTP::header Location] contains "www.reaxis.com?" } {
        HTTP::header remove Location
        log local0. "the location made match on the IF"
        HTTP::respond 302 Location "https://www.reaxis.com" Server CompaniXServer 
    }
    
    • Cristian_Daniel's avatar
      Cristian_Daniel
      Icon for Nimbostratus rankNimbostratus
      Thank you for your response, I made the changes and doesn't work, I think that maybe I'm getting bad the event, because this is on a APM.
  • Christian, there might be some details missing here. On a simple APM access policy the above iRule from Thomas should work. Can you elaborate on what you have configured?

     

    Also, your first log statement will always fire, on every response, though the variable may be empty if the response is not a redirect. Not sure if that was your intention.

     

  • Just spitballing here, but there's a minor spelling difference between what you're getting and what you're looking for.

    Dec 20 08:01:54 vpn1test info tmm[16509]: Rule /Common/test_apm_i2c : https://www.reaxys.com? this made match! 
    

    Notice "reaxys" vs. "reaxis".

    if { [HTTP::header Location] contains "www.reaxis.com?" } {