Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Clear all filters
Answers

Redirect Include URI

Hi

I'm having trouble with the following iRule.

The requirement is to redirect any requests to https://download.test.back.com to https://download.test.back.com/bred/publicweb/status/gifb

Any requests directly to https://download.test.back.com/bred/publicweb/status/gifb should be rejected

when HTTP_REQUEST { if { [HTTP::host] equals "download.test.back.com" && [HTTP::path] equals "/" } { HTTP::redirect "https://[HTTP::host][HTTP::uri]/bred/publicweb/status/gifb"

        }else {          
    if {[HTTP::uri] equals "/bred/publicweb/status/gifb" } {
    reject
    }
}

}

The response we are seeing towards the servers is something like this does not include the URI (/bred/publicweb/status/gifb)

----------------------------REQUEST--------------------------- URI=/MEkwRzBFMEMwQTAJBgUrDgMCGgUABBQ6UnYMs4JZvSkqZMdaftSSm1KopgQUIT1LBSePsKHPrvwmssmkgd76sn4CCHCEWSkqZPMv

I would like URL to be included on the way to the servers, like this:

----------------------------REQUEST--------------------------- URI=/bred/publicweb/status/gifb/MEkwRzBFMEMwQTAJBgUrDgMCGgUABBQ6UnYMs4JZvSkqZMdaftSSm1KopgQUIT1LBSePsKHPrvwmssmkgd76sn4CCHCEWSkqZPMv

Can someone point me in the right direction?

Thanks

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

I guess this code may do what expected

when HTTP_REQUEST { 
    if { [HTTP::host] equals "download.test.back.com" && [HTTP::path] equals "/" } {     
        HTTP::redirect "/bred/publicweb/status/gifb[HTTP::uri]"

        } elseif {[HTTP::uri] equals "/bred/publicweb/status/gifb" } {
    HTTP::respond 403 content {request rejected}
    }
}
0
Comments on this Answer
Comment made 14-Sep-2018 by southern_shredder 63

Thanks for the response, but it seems the new URI is still not attaching like it does when we go directly to the webserver.

Directly to the Server (URI in path)

URI=/bred/publicweb/status/gifb/MEkwRzBFMEMwQTAJBgUrDgMCGgUABBQ6

Directly to the VIP (NO URI)

URI=/MEkwRzBFMEMwQTAJBgUrDgMCGgUABBQ6

Would it make a difference if we used replace instead of redirect?

HTTP::header replace

0
Comment made 14-Sep-2018 by Stanislas Piron 10481

it makes a big difference!

when HTTP_REQUEST { 
    if {[HTTP::host] equals "download.test.back.com" && [HTTP::uri] starts_with "/bred/publicweb/status/gifb" } {
        HTTP::respond 403 content {request rejected}
    } elseif { [HTTP::host] equals "download.test.back.com" } {     
        HTTP::uri "/bred/publicweb/status/gifb[HTTP::uri]"

    }
}
0
Comment made 16-Sep-2018 by southern_shredder 63

Hi, this worked perfectly. Thanks!Exactly what we were looking for

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Do you want to:

  • redirect /foo to /bred/publicweb/status/gifb/foo
  • deny /bred/publicweb/status/gifb
  • allow everything starting with /bred/publicweb/status/gifb/

Redirect means there is a 302 response to client who send a new request with new URI!

0
Comments on this Answer
Comment made 11-Sep-2018 by southern_shredder 63

Hi

Yes, we would like to

  • redirect everything to /bred/publicweb/status/gifb if the request is https://download.test.back.com/ and the full path must be sent (host, uri)

  • Deny any direct requests to /bred/publicweb/status/gifb

That makes sense about the 302 response. How can we include the new URI path (https://download.test.back.com//bred/publicweb/status/gifb) in the GET request after the redirect has occured?

0
Comment made 12-Sep-2018 by southern_shredder 63

Is there a different way to write this irule besides invoking a 302 response? Just forward all requests to "/bred/publicweb/status/gifb"?

0