Forum Discussion

subhasish_prati's avatar
subhasish_prati
Icon for Nimbostratus rankNimbostratus
Jan 16, 2019

irule not working

I am using the below irule in the WIP and the outcome expected is when the extension is exp it should direct to specific IP address and respectively for other extension . I am able to see increase in total execution every time I try to access the WIP but not able to see the desired out put on the tcpdump . The packet is not getting translated to a.b.c.d:8082 and respectively for other requests .

 

HTTP_REQUEST { when HTTP_REQUEST { if { [HTTP::uri] contains "/exp" } { log local0. "Sending request to exp" HTTP::respond 301 "Location" "https://a.b.c.d:8082/exp"; } elseif { [HTTP::uri] contains "/proc" } { log local0. "Sending request to proc" HTTP::respond 301 "Location" "https://a.b.c.d:8080/proc"; } elseif { [HTTP::uri] contains "/sys" } { log local0. "Sending request to sys" HTTP::respond 301 "Location" "https://a.b.c.d:9043/sys"; } }

 

1 Reply

  • Hi Subhasish Pratihar,

    the command

    HTTP::respond 301 "Location" "https://a.b.c.d:8082/exp"
    will send a HTTP response to the clients informing them that the resource has been "Moved Permanently" to the new location
    https://a.b.c.d:8082/exp
    .

    The clients will send then a new request directly to the URL

    https://a.b.c.d:8082/exp
    and should also cache the new location locally, so that subsequent request will be redirected within the browser without sending any traffic to the old location...

    Is this what you are trying to accomplish? I'm asking because lots of users are getting confused with terms "redirect to a different site" and "forward the ongoing request to a given backend pool".

    Cheers, Kai