Forum Discussion

NielsH_187296's avatar
NielsH_187296
Icon for Nimbostratus rankNimbostratus
Feb 15, 2015

Rewriting HOST+URI does not work

Hi,

 

I'm using the following iRule to let the BigIP redirect a request for /webfront to website-webfront.domain.com. The redirecting should go via the BigIP, not via the client.

 

Source: http://pastie.org/private/lx2ds7ibjodwjgs7ayy95g

 

However, it never goes as planned. I either get a redirect loop, 404 or redirect to /webfront/webfront or something like that.

 

Edit: We're running version 11.5.1. The content we're loading is inside an iframe.

 

Any suggestions? Thank you.

 

14 Replies

  • your irule is confusing. Do you want webfront-web.domain.com or web-webfront.domain.com?

    try this:

        if { ([HTTP::uri] starts_with "/webfront") } {
             change host name option 1
            HTTP::host "webfront-[HTTP::host]"
             or option 2
            HTTP::host "[substr [HTTP::host] 1 ".domain.com"]-webfront.domain.com"
    
             trim uri
            HTTP::uri [string map {"/webfront" ""} [HTTP::uri]]
    
        }
    
  • your irule is confusing. Do you want webfront-web.domain.com or web-webfront.domain.com?

    try this:

        if { ([HTTP::uri] starts_with "/webfront") } {
             change host name option 1
            HTTP::host "webfront-[HTTP::host]"
             or option 2
            HTTP::host "[substr [HTTP::host] 1 ".domain.com"]-webfront.domain.com"
    
             trim uri
            HTTP::uri [string map {"/webfront" ""} [HTTP::uri]]
    
        }
    
  • Hi, I just tested this one:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::uri]] starts_with "/webfront" } {
            set subd [getfield [HTTP::host] ".domain.com" 1]
             log local0. "subd: <$subd>"
            if { $subd contains "-dmz" } {
                set subd [string map {"-dmz" ""} $subd]
            }
            HTTP::header replace Host "${subd}-webfront.domain.com"
            HTTP::uri [string map {"/webfront" ""} [HTTP::uri]]
        }
    }
    

    Thanks, Stephan