Forum Discussion

wrightnz_34708's avatar
wrightnz_34708
Icon for Nimbostratus rankNimbostratus
Jul 08, 2010

ProxyPass

Hi - hope this is the right place to pose this question

 

Background:

 

We are using the ProxyPass irule v10.2 to setup URI shortcode/keyword redirects (rewrites?) e.g. www.123.com/checkthisout redirecting to www.123.com/tabid/1111/Default.aspx?showid=18828" while retaining/cloaking the redirected URI i.e. only www.123.com/checkthisout displays in the browser address area.

 

Problem:

 

Our interactive team does not want the redirected URI to be cloaked and wants it to be displayed in full in the browser address area e.g. user enters www.123.com/checkthisout into browser and is redirected to www.123.com/tabid/1111/Default.aspx?showid=18828" with this full address appearing in their browser address area.

 

Question:

 

Can ProxyPass be configured to show the full URI of the redirect instead of 'cloaking' it?

 

8 Replies

  • If you send an HTTP redirect, the client will see the change in their address bar. If you rewrite the URI and/or host before sending the request to the server, the client will not see the change. So in concept you could modify the ProxyPassv10 iRule to send a redirect instead of rewriting the URI, but you'll need to strip out a fair amount of code related to the rewriting. You can send a 302 redirect with HTTP::redirect or any HTTP response with HTTP::respond.

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/http__redirect

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/http__respond

     

     

    Aaron
  • Thanks!

     

     

    If I can't get ProxyPass to work this way and use HTTP:respond instead - how could I write an HTTP::respond for multiple redirects in the same irule

     

     

    e.g. this is how I'd do one for a single redirect at the moment

     

     

    -----------------------------

     

    when HTTP_REQUEST {

     

    switch [string tolower [HTTP::host]] { "123.com"

     

    {

     

    HTTP::respond 301 Location "http://www.123.com[HTTP::uri]"

     

    }

     

    }

     

    }

     

    ----------------------------

     

     

    My proxypass DataGroupList external file /config/ProxyPass123 contains multiple redirects like

     

     

    "www.123.com/land" := "www.123.com/Shows/land/tabid/26/Default.aspx",

     

     

    "www.123.com/aw" := "www.123.com/Shows/Advanced/tabid/45/Default.aspx",

     

     

    "www.123.com/attack" := "www.123.com/Shows/Attack/tabid/14/Default.aspx",

     

     

    "www.123.com/plenty" := "www.123.com/Shows/Plenty/tabid/27/Default.aspx",

     

     

    "www.123.com/blogs" := "www.123.com/Shows/Blogs/tabid/93/Default.aspx",

     

     

    "www.123.com/OP" := "www.123.com/Shows/Plenty/tabid/57/Default.aspx",

     

     

    "www.123.com/derbury" := "www.123.com/Shows/derbury/tabid/58/Default.aspx",

     

     

    "www.123.com/Central" := "www.123.com/Shows/Central/tabid/29/Default.aspx",

     

     

    "www.123.com/channel" := "www.123.com/Shows/tabid/397/Default.aspx",

     

     

    "www.123.com/church" := "www.123.com/Shows/derbury/tabid/58/Default.aspx",

     

     

    "www.123.com/events" := "www.123.com/Events/tabid/699/Default.aspx",
  • Here is an example which checks the HTTP path (set to lower case for IIS apps) and sends a 301 response based on the datagroup entries you have above. Note that I've removed all checks of the host. If you want to add handling for other hosts, you can put the switch inside a check on HTTP::host. If you want to check if the requested path starts with the strings, you can add the -glob flag to the switch and add a * to the end of the path(s):

    switch wiki page

    http://devcentral.f5.com/wiki/default.aspx/iRules/switch

    
    when HTTP_REQUEST {
    
        Set the path to lowercase 
       switch [string tolower [HTTP::path]] {
          "/land" {
             HTTP::respond 301 Location "/Shows/land/tabid/26/Default.aspx"
          }
          "/aw" {
             HTTP::respond 301 Location "/Shows/Advanced/tabid/45/Default.aspx"
          }
          "/attack" {
             HTTP::respond 301 Location "/Shows/Attack/tabid/14/Default.aspx"
          }
          "/plenty" {
             HTTP::respond 301 Location "/Shows/Plenty/tabid/27/Default.aspx"
          }
          "/blogs" {
             HTTP::respond 301 Location "/Shows/Blogs/tabid/93/Default.aspx"
          }
          "/op" {
             HTTP::respond 301 Location "/Shows/Plenty/tabid/57/Default.aspx"
          }
          "/derbury" {
             HTTP::respond 301 Location "/Shows/derbury/tabid/58/Default.aspx"
          }
          "/central" {
             HTTP::respond 301 Location "/Shows/Central/tabid/29/Default.aspx"
          }
          "/channel" {
             HTTP::respond 301 Location "/Shows/tabid/397/Default.aspx"
          }
          "/church" {
             HTTP::respond 301 Location "/Shows/derbury/tabid/58/Default.aspx"
          }
          "/events" {
             HTTP::respond 301 Location "/Events/tabid/699/Default.aspx"
          }
          default {
              Take some default action?
          }
       }
    }
    

    Aaron
  • One more question if I may... can wildcards be used e.g. using siteurls.config to look for characters in URI and redirect

     

     

    [RewriterRule]

     

    [LookFor].*tabid/786/.*[/LookFor]

     

    [SendTo]http://www.123.com/error404.aspx[/SendTo]

     

    [/RewriterRule]

     

     

    Could I change this to an iRule as follows - how would you use string match for glob style wildcard pattern matching: (string match "*/tabid/786/*" [HTTP::uri])

     

     

    Would this work?

     

     

    when HTTP_REQUEST {

     

    Set the path to lowercase

     

    switch -glob [string tolower [HTTP::uri]] {

     

    "*/tabid/786/*" {

     

    HTTP::respond 301 Location "http://www.123.com/error404.aspx"

     

    }

     

    }

     

    }

     

     

  • That looks exactly correct. If as in your original post, you want to check for multiple patterns that use the same action, you can group them using a -

    
    when HTTP_REQUEST {
        Set the path to lowercase
       switch -glob [string tolower [HTTP::uri]] {
          "*/tabid/737/*" -
          "*/tabid/746/*" -
          "*/tabid/786/*" {
             HTTP::respond 301 Location "http://www.123.com/error404.aspx" 
          } 
       }   
    }
    

    Aaron
  • AWESOME!

     

     

    Changed slightly to :

     

     

    ----------------------------------------------------------------------

     

    when HTTP_REQUEST {

     

     

    Set the path to lowercase

     

    switch -glob [string tolower [HTTP::uri]] {

     

    "*tabid/737/*" -

     

    "*tabid/746/*" -

     

    "*tabid/786/*" {

     

    HTTP::respond 301 Location "http://www.123.com/error404.aspx"

     

    }

     

    }

     

    }

     

    -----------------------------------------------------------------------

     

     

    Thanks again!