Forum Discussion

bdub66_173164's avatar
bdub66_173164
Icon for Nimbostratus rankNimbostratus
Oct 10, 2014

reverse proxy one server, multiple uri's

Used a rule in this thread. Troy's response actually.

 

This one site has multiple redirects off port 7004. The initial site connects with the cert and offloads to the client. the other 2 sites do not display the cert but display the data anyhow. I assume because of the server redirects.

 

from my rule the only site that works is console-selfservice and that's whats currently on http://site:7004/. Here is my rule: when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains ("/console-selfservice/") } { HTTP::header replace "Host" site:7004 }

 

if { [string tolower [HTTP::uri]] contains ("/console-selfservice/TroubleShooting/") } { HTTP::header replace "Host" site:7004}

 

if { [string tolower [HTTP::uri]] contains ("/IMS-AA-IDP/sso/") } { HTTP::header replace "Host" site:7004}

 

}

 

when HTTP_RESPONSE { HTTP::header replace Location [string map -nocase {site:7004 site:7004} [HTTP::header value Location]] }

 

can we have more than one condition for HTTP_REQUEST rule? from my experience with the ACE it would look like the uri isn't getting matched and not displaying the webpage.

 

4 Replies

  • Hi mate!

    I'm not following what you need actually, but let me brush up your syntax a bit so it's easier for us to understand your rule (I added a check for redirects so the iRule does not add location into every request):

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] contains ("/console-selfservice/") } { 
            HTTP::header replace "Host" site:7004
        }
    
        if { [string tolower [HTTP::uri]] contains ("/console-selfservice/TroubleShooting/") } { 
            HTTP::header replace "Host" site:7004
        }
    
        if { [string tolower [HTTP::uri]] contains ("/IMS-AA-IDP/sso/") } { 
            HTTP::header replace "Host" site:7004
        }
    }
    
    when HTTP_RESPONSE { 
    
        if { [HTTP::is_redirect] } {
            HTTP::header replace Location [string map -nocase {site:7004 site:7004} [HTTP::header value Location]]
        }
    }
    

    One other thing that you might want to consider is that if the second if is true, the first one is as well. Maybe that's not an issue for you, but maybe you want to do an if-else instead?

    Could you please explain a bit more thorough what you want to happen with this irule, step by step?

    /Patrik

  • Hi Patrik,

     

    Thanks for the reply, an if-else is probably what I was really asking about instead of the possibility for multiple instances inside an irule. Meaning if not the initial site /console-selfservice/ then the login portion of the site on port 7004 also.

     

    To be a little more thorough though.

     

    While the initial site works /console-selfservice/ (gets the url-rewrite and displays the page) any other action taken from here has a redirect coming from the server and displaying the /IMS-AA-IDP/ page with no url rewrite. That means there has to be something in the http_response section doesn't it? The re-write I am using just strips away the 7004 and displays the name on the cert.

     

    If I enter data on the IMS-AA-IDP page (basically a login) depending on the browser used gets different results on the rewrite but doesn't display a page.

     

    /Brian

     

  • well, ended up going much simpler. guess I was not paying attention to the http_response

     

    much appreciated and thanks again for the reply.

     

    ending irule

     

    when HTTP_REQUEST { if { [HTTP::header host] eq "sitefqdn" } { HTTP::header replace Host "serverfqdn:7004" } }

     

    when HTTP_RESPONSE { if { [HTTP::is_redirect] } { HTTP::header replace Location [string map -nocase {serverfqdn:7004 sitefqdn} [HTTP::header value Location]] } }