Forum Discussion

blwavg_10621's avatar
blwavg_10621
Icon for Nimbostratus rankNimbostratus
Aug 13, 2013

Redirect Rewrite - F5 to Server Only

Hey,

We are moving from IIS to F5. I am having trouble with an invisible URI rewrite. My configuration is something like this:

Inbound Rule:
Pattern: .*
Condition: 
        Input: {HTTP_HOST}
        Type: Matches The Pattern
        Pattern: website.company.com
Action: Route to Server Farm
Action Properties:
        Scheme: HTTPS://
        Sever Farm: SERVER01_Farm
        Path: /URI_REWRITE_PATH_HERE

Basically when a client connects to website.company.com the IIS server sends the request back to the servers with the appended URI. The client still only sees HTTPS://website.company.com/ in their browser. I need to keep this kind of continuity because we have some static URLs that fail WCF service calls.

The best irule I have come up with is (witch only appends the URI:

when HTTP_REQUEST {
   if { [HTTP::uri] == "/" } {
      HTTP::uri "/URI_REWRITE_PATH_HERE" 
   }
}

11 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    Do you have a specific question?

     

    One potential problem I see is that you're checking for "/". However, a request that includes the filename of the default document (e.g. "/default.aspx") should be treated as if it were "/".

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account

    So are you looking to have their entire browsing experience only show website.domain.com/? Meaning you want to remove any URI context that the servers return back each time, so that it isn't visible in the URI? (Note: This is not advised and can lead to some ... interesting issues). If so, then you'll need to add a response section and do some more advanced legwork as well.

     

    If all you're trying to do is seamlessly re-write the URI to the new path then you're pretty close. You may want to consider adding a couple more cases such as a blank URI or, as Arie above said, a default document name that also get re-written. The functionality you already have, however, should be pretty much what you need to invisibly re-write website.domain.com/ to website.domain.com/SOME_URI without the client seeing the change.

     

    Colin
    • blwavg_10621's avatar
      blwavg_10621
      Icon for Nimbostratus rankNimbostratus
      Over IIS, it only shows website.domain.com/ for the client and when I do it over the F5 is shows the full URI. Which is a pretty easy setup in IIS, so why do you think this specifically would cause problems? Something I just noticed that I should add it that this site does add a tag of Home. So the client sees HTTPS://website.company.com/Home. I do not know if that makes a difference. When I use my basic iRule above it does the same thing with the full URI path shown. I also do not know if IIS it taking the URL and rewriting to the be servername.company.com/URI_REWRITE_PATH_HERE.
  • are you wanting to rewrite or redirect? Rewrite will not change client behavior, redirect will.
  • Quick question. In IIS, when you make a several different requests for things, how does the server know, by virtue of the request parameters, what the client is asking for? Is everything under a single URI and you're using Ajax/JavaScript and hash tags to move around? Do you find it difficult to bookmark specific pages of your site?

     

    If everything IS under a single URI, then that should be easy to fix with an iRule and HTTP::uri translation.

     

  • There is no redirect above. You are rewriting the server side URI, but in HTTP a redirect is a specific HTTP 30x response code that causes the client to go to a URL. The iRule you need would do 3 things: 1) rewrite the HTTP::uri from /* to /URI_REWRITE_PATH_HERE/* 2) change the HTTP::host from website.company.com to whatever the backend is expecting 3) select the proper backend pool (SERVER01_Farm) Alternatively the proxypass irule does all of this and much more, and in 11.4+ you can just use the built in central policy matching stuff to do it.
  • To fix this issue, I upgraded to 11.4HF3. They broke out the rewrite option from APM (AWESOME!!!). I then configured this under Profiles > Services > Rewrite: Rewrite Mode: URI Translation URI Rules - Client "/" Server "/uri_rewrite_path_here/" Type "Both" NOTE: Everthing else was default.
  • Yep, we have Local traffic policies in 11.4 which replace the HTTP classes in prior versions. These allow for much more functional handling of traffic beyond just HTTP. Local traffic policies - https://support.f5.com/kb/en-us/products/big-ip_ltm/manuals/product/ltm-concepts-11-4-0/3.html?sr=31264929 https://support.f5.com/kb/en-us/products/big-ip_ltm/releasenotes/product/relnote-ltm-11-4-0.html Local Traffic Policies In this release, you can use BIG-IP local traffic policies that comprise a prioritized list of rules matching defined conditions and running specific actions, which you can assign to a virtual server that directs traffic accordingly. For example, you might create a policy that determines whether a client's browser is a Chrome browser and adds an Alternative-Protocols attribute to the header, so that subsequent requests from the Chrome browser are directed to a SPDY virtual server. Or you might create a policy that determines whether a client is using a mobile device, and then redirects its requests to the applicable mobile web site's URL.
  • This has a decent number of hits so I want to clarify my solution. I upgraded to 11.4 for the rewrite capabilities.

     

    I configured this under Profiles > Services > Rewrite: Rewrite Mode: URI Translation URI Rules - Client "/" Server "/uri_rewrite_path_here/" Type "Both" NOTE: Everthing else was default.

     

    The only other solution I could find was using the proxypass irule (found here https://devcentral.f5.com/wiki/iRules.proxypassv10.ashx). That is if you cannot perform an upgrade.

     

  • Marvin's avatar
    Marvin
    Icon for Cirrocumulus rankCirrocumulus
    comment==> To fix this issue, I upgraded to 11.4HF3. They broke out the rewrite option from APM (AWESOME!!!). What do you exactly mean that URL rewriting is now available in the BIG IP APM 11.4HF3, that is just the thing I am waiting for. Can you confirm that it is now possible to rewrite from http:\\domain.com to https:\\www.domain.com for example? Is there no need to buy a separate LTM license?