Forum Discussion

assaf_benedic_1's avatar
assaf_benedic_1
Icon for Nimbostratus rankNimbostratus
Aug 31, 2006

redirecting HTTP traffic based on the HTTP method type (GET, POST, etc.)

 

Hi ,

 

 

 

How can I redirect traffic based on HTTP method type?

 

 

 

I tried the following iRule:

 

 

when HTTP_REQUEST

 

lf { [HTTP::method] contains "GET" }{

 

log "forwarding [HTTP::method] method to the web"

 

 

meaning - not redirecting GET requests to my HTTP servers.

 

}

 

else {

 

log "redirecting [HTTP::method] method to HTTP servers"

 

}

 

}

 

 

When HTTP GET requests were received, I noticed that the "if" was true but the BigIP redirected the traffic to the HTTP servers and not forwarded the packets directly to the internet.

 

As far as I know "forward" sends the packets according to the routing table.

 

Did I do something wrong?

 

 

 

Thanks in advance,

 

 

Assaf.

 

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Your rule needs to specify in the "if" and "else" clauses how you'd like the traffic to be managed. What you have there is simply logging the indicated messages and sending all requests to the default pool defined for the virtual.

    I'm not sure exactly what you mean by "forwarding to the web" and "redirecting to servers", but you probably need something more like:
    when HTTP_REQUEST {
      if { [HTTP::method] contains "GET" }{
        log "forwarding [HTTP::method] method to the web"
        pool forwarding_pool
      } else {
        log "redirecting [HTTP::method] method to HTTP servers"
        pool server_pool
      }
    }
    where "forwarding_pool" and "server_pool" are pools defined with the intended destinations.

    HTH

    /deb

  • Hi,

     

     

    I added a draw to better understanding (it was uncleared before, sorry).

     

     

    By forwarding I mean:

     

     

    sending the traffic from the client to the internet without redirecting the traffic to the HTTP proxy (according to the routing table and not a certin pool).

     

     

    client ----- BigIP ----- internet

     

    |

     

    HTTP PROXY

     

     

    By redirecting I mean :

     

    1. The client sends http requests to the internet (dest IP - web).

     

    2. The BigIP gets the packets, checks if it's not a GET request.

     

    if not, the GET request is redirected to the HTTP PROXY.

     

     

     

    Thanks again,

     

     

    Assaf.
  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    What you probably want is more like this:
    when HTTP_REQUEST {
      if { [HTTP::method] eq "GET" }{
        log "forwarding [HTTP::method] method to the web"
        forward
      } else {
        log "redirecting [HTTP::method] method to HTTP servers"
        pool proxy_pool
      }
    }
    Where proxy_pool contains your proxy servers.