URI Rewrite for Server Pool

I have an issue which after reviewing numerous other posts…isn’t covered.

I have a site connected to a server pool that is accessed by a normal URL (http://website.domain.com), but returns the server name, access port, and directory (http://servername:5555/directory).

The problem is that I need the Server Name Portion stripped on the return to the Browser, but the IRule needs to be able to do this for a Server Pool of 2 or more servers.

In addition anything past the URI / must remain unchanged. I’ve tried several solutions the following being the last to no avail.

when HTTP_RESPONSE_CONTINUE {

set newhost “http://website.domain.com”

if { [HTTP::header host] contains “servername:5555/” } {

HTTP::header replace host $newhost

}

}

Can someone help me or point me in the right direction?

A few corrections. In the HTTP protocol, the server does not return a server name and location as part of the HTTP response.

Here’s a trace for a request for http://www.foo.com/index.html

GET /index.html HTTP/1.0

User-Agent: browser-id-string

Host: www.foo.com

Pragma: no-cache

Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

and here’s the response:

HTTP/1.1 200 OK

Date: Wed, 15 Nov 2006 19:00:12 GMT

Server: server-id-string

Last-Modified: Fri, 18 Mar 2005 15:33:33 GMT

ETag: “75e5-ced-19dd0d40”

Accept-Ranges: bytes

Content-Length: 3309

Connection: close

Content-Type: text/html; charset=ISO-8859-1

Content…

As you’ll see there is no Host header in the response, nor any host or uri indication whatsoever.

The URI in the browser is based on the URL in the initial request. A server can opt to change this by issuing a HTTP Redirect (ie. a HTTP 301 response) to the browser with the Location Header containing the alternate URL to then connect to.

With that being said, I can only assume that you would like the BIG-IP and iRules to do the 30x redirection for you. This can be done by changing the Host header in the request like this

HTTP::header replace "Host" "servername:5555"

and changing the URI with the HTTP::uri command

HTTP::uri "/directory[HTTP::uri]"

You may want to do something different with the uri but you get the point.

One other thing I noticied is that you took the host to contain the protocol (ie http://). This is not the case. The host is the section right after the protocol and before the first slash.

So for this uri: http://servername:5555/directory/index.txt, the value of HTTP::host is “servername:5555” and HTTP::uri is “/directory/index.txt”.

BTW, in the future, you might want to post these types of questions to the iRules v9x forum as this forum is for questions regarding the iRules Editor application.

-Joe

ok