Forum Discussion

IBlackthorn_385's avatar
IBlackthorn_385
Icon for Nimbostratus rankNimbostratus
Mar 06, 2019

Help configuring an iRule to rewrite a host and url path being sent to a back-end server

We’re attempting to configure our F5 to act as a reverse proxy to rewrite URLs and we’re running into an issue with our iRule. We’ll be using this for 10 or so pools so if there is a better way of accomplishing this please let us know. Also, we’re starting out with HTTP just to get it working. We’ll eventually want to include HTTPS but have the F5 terminate the HTTPS connection and have the connection from the F5 to the backend server over HTTP.

 

Externally clients would hit the following url – proxy.example.com/sitename/randomsubfolder/randompaths The sitename would be a static/constant value that we’ll know/control The sitename will specify what F5 Pool to use

 

When the F5 directs the request to the internal server, we need it to do the following: We need to rewrite the host to sitename.example.com Remove the /sitename Keep the trailing/random subfolders/random paths after the site name and pass it through without making changes

 

Using the example above the server should see the request as - sitename.example.com/randomsubfolder/randompaths

 

Here’s the rule we’ve attempted so far but haven’t had any luck

 

Existing Pool Name = tdevf5app01_pool

 

when HTTP_REQUEST { if { [string tolower [HTTP::host]] eq " proxy.example.com " and [HTTP::path] contains "/tdevf5app01site" } { set uri [HTTP::uri [string map {"/tdevf5app01site" ""} [HTTP::uri]]] HTTP::header replace host tdevf5app01.example.com HTTP::path "/$uri" pool TDEVF5APP01_Pool } }

 

Any help would be greatly appreciated. Thanks!

 

No RepliesBe the first to reply