Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Replace server name

Mr__T
Cirrus
Cirrus

Hello All,

I am looking to replace the FQDN of a URL with the server name keeping the remainder of the URL after the FQDN. Trying to find the simplest way to acheive this. Dont want to redirect the entire URL, just swap the FQDN.

5 REPLIES 5

JRahm
Community Manager
Community Manager

Hi @Mr__T so you are just wanting to rewrite the Host header in the communication from client->BIG-IP->server, but not issue a redirect, correct? You can do that in an LTM policy or in an iRule.

Policy

 

ltm policy host_rewrite {
    last-modified 2023-09-19:14:47:44
    requires { http }
    rules {
        host_rewrite_all_traffic {
            actions {
                0 {
                    http-header
                    replace
                    name Host
                    value new.fqdn.com
                }
            }
        }
    }
    status published
    strategy first-match
}

 

iRule

 

when HTTP_REQUEST priority 500 {
    HTTP::header replace host "new.fqdn.com"
}

 

Note that this is not rewriting the location headers being returned from the server, and is assuming they are a) returning the original fqdn and b) are fine receiving a rewritten host. If that's the not the case, you'll need to do some more work. Post back with more details if necessary. HTH...Jason

Thanks @JRahm . Let me try the iRULE

whisperer
Cumulonimbus
Cumulonimbus

Is one of the requirements to rewrite the request differently depending on the pool member chose. during the LB selection? For example, if you have 2 origin servers, they probably have unique names. So the rewrite may have to match the server that is selected on the server side of the connection.

Correct, 2 servers that can't use FQDN. Wont be LB per say more like failover. 

Kerry
Altocumulus
Altocumulus

note: 

pool member is selected after the first http request.  you need to forces the selection.  if you planning "if pool member x then host names y" 

or create two pools.   once for each FQDN name.   "if (pool 1 no members) then (host name y + user pool 2) else (host name x)"