Application Delivery (ADX)

How do I rewrite the HTTP host header

by on ‎05-28-2009 12:20 AM - edited on ‎10-30-2013 05:42 PM by bcm1 (843 Views)

Summary

Rewriting the existing host header of the HTTP request when the HTTP request passes the ServerIron

Specifics

Some web server/applications require the host header to be rewritten/altered for application compatibility on real server(s). Clients connect to the virtual server in front of the real servers using the FQDN of the virtual server as host header. A virtual server with the IP address a.b.c.d might be known as www.whatever.com and incoming HTTP requests would have the following host header:

 

Host: www.whatever.com

 

 

The example below covers the following case:

The load balancer/ServerIron might do a port mapping on the way to the real servers. Incoming requests do use port 80 but the real server do listen at port 81. The real servers need to see their own port in the host header in some cases to prevent application problems. The header

 

Host: www.whatever.com needs to get changed to

Host: www.whatever.com:81

 

 

Sample Script/Code/Configuration

 

csw-rule "www.whatever.com" header "host" equals "WWW.WHATEVER.COM" case-insensitive

 

 

csw-policy "pol" case-insensitive

  match "www.whatever.com" forward 1

  match "www.whatever.com" rewrite request-insert ":81"

 

server real rs101 1.2.3.4

  port 81

  port 81 group-id 1 1

 

server virtual vs222 192.168.8.222

  port http

  port http csw-policy "pol"

  port http csw

  bind http rs101 81

 

 

Tips / Caveats

 

 

 

Further Reading

Contributors