Forum Discussion

Deniz_112317's avatar
Deniz_112317
Icon for Nimbostratus rankNimbostratus
Nov 14, 2011

iRule is resulting in error 404 after execution

I have the following irule configured to pass traffic to our app servers...

 

 

when HTTP_REQUEST {

 

set uri [HTTP::uri]

 

 

if { $uri starts_with "/firstEnv" } {

 

pool firstEnv

 

 

} elseif { $uri starts_with "/secondEnv" } {

 

pool secondEnv

 

 

} elseif { $uri starts_with "/thirdEnv" } {

 

pool thirdEnv

 

 

} else {

 

HTTP::redirect

 

}

 

}

 

 

 

 

 

The first two statements work the way they are supposed to, however, the third one does not. It returns a 404 error. This error is the same as one I would receive if I misstyped the "/firstEnv" switch after the URL, however, it is correct. I can go directly to the app servers (bypassing the F5) with the appropriate port and syntax and I have no issues there.

 

 

Here's the kicker... If I swith the first and the third "environments" in the irule, it is still the third one that doesn't work and the first one that does. Am I missing a step in my statement?... the F5 points the the app server being the problem, but the ability to get to the application directly implies that it's an issue with the F5.

 

 

Any help would be appreciated.

 

 

 

 

 

 

 

 

1 Reply

  • Can you add a OneConnect profile to the virtual server and retest? If you're using SNAT you can use the default OneConnect profile. If you're not doing serverside source address translation, you should create a custom OneConnect profile with a /32 source mask.

    Here's an iRule which should give better performance than the if/elseif/.../else chain:

    
    when HTTP_REQUEST {
    
    switch -glob [HTTP::uri] {
    "/firstEnv*" {
    pool firstEnv
    log local0. "[IP::client_addr]:[TCP::client_port]: pool firstEnv for [HTTP::uri]"
    }
    "/secondEnv*" {
    pool secondEnv
    log local0. "[IP::client_addr]:[TCP::client_port]: pool secondEnv for [HTTP::uri]"
    }
    "/thirdEnv*" {
    pool thirdEnv
    log local0. "[IP::client_addr]:[TCP::client_port]: pool thirdEnv for [HTTP::uri]"
    }
    default {
    HTTP::redirect "https://[HTTP::host]/firstEnv"
    log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting for [HTTP::uri]"
    }
    }
    }
    when HTTP_RESPONSE {
    log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::status] response"
    }
    

    Aaron