Forum Discussion

Tosin_Omojola's avatar
Tosin_Omojola
Icon for Altostratus rankAltostratus
Aug 03, 2016

How to Add a query string to a pass to a pool

Hi all,

I have this challenge and need your help urgently please.

I want to access this url: http://10.10.1.57:9001/banks and want the request arrive at the pool like this:

http://10.10.1.57:9001/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks

The full url above is the direct url which is accessible in itself. Loadbalancing to pools happens after the VS receives the string above in HTTP_REQUEST. Please, I need an iRule to do this.

Thanks

6 Replies

  • Hi Sadorect,

    you could either trigger a client side

    HTTP::redirect
    for the
    HTTP::path
    "/banks" redirecting the client to the given destination site...

    when HTTP_REQUEST { 
        if { [string tolower [HTTP::path]] eq "/banks" } then {
            HTTP::redirect "/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks"
        }
    }
    

    ... or you could transparently rewrite the

    HTTP::uri
    while beeing forwarded to your backend system...

    when HTTP_REQUEST {     
        if { [string tolower [HTTP::path]] eq "/banks" } then {
            HTTP::uri "/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks"
        }
    }
    

    Cheers, Kai

  • Look at ProxyPass. You can find it in the code repository of DevCentral:

     

    https://devcentral.f5.com/codeshare/proxypass-v10-v11

     

  • Presently, I have the following iRule attached to the VS and the iRule correctly redirected to the specified url but This page can't be displayed error came up. What am I doing wrong please or what more do I need to add?

    when HTTP_REQUEST {
      set query_args "http://10.10.1.57:9001/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks"
         HTTP::redirect "$query_args" 
    }
    
  • Hi,

    I believe all you need to do is a basic URI match and change the URI:

    when HTTP_REQUEST {
       if { [HTTP::uri] equals "/banks" } {
          HTTP::uri "/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks" 
       }
    }
    

    This assumes an exact match on the URI you're looking for.

  • Hi Sadorect, The problem with your iRule is, that you trigger the HTTP::redirect on every single HTTP::request. In this case a redirect loop will most likely ocour, since the redirects will be redirected again and again and again. Look at the code examples of my answer below. Both examples will make sure that the HTTP redirect (example 1) or URI rewrite (example 2) will only become triggered, if the user accesses http://10.10.1.57:9001/banks. Every other URI will then become forwarded without triggering the redirect/rewrite again. Note: Feel free to change /banks to just /. In this case your users can use http://10.10.1.57:9001/ to start the application...

     

    Cheers, Kai

     

  • Alright guys. I did it. I just discovered that the iRule required that the redirect be forwarded to a different address and NOT the VIP itself. So, I created another VS, and put the iRule on it to redirect to what I have in the question.

     

    Thanks for your help!