Forum Discussion
Http header
Hi All,
I wanted to insert http header on URL for backend server selection .So if XYZ.abc.com is URL and if the traffic hits the F5,it should insert header of backend server ,say server 1 ,so request should go to server 1 .I have multiple server in backend so not sure how i can achieve this .What are the best option to do that .
Is their any impact on F5?
2 Replies
- nitass
Employee
do you mean you want to select server and insert http header based on hostname in url (host header)?
if yes, you can check host header using HTTP::host and insert header using HTTP::header command.
HTTP::host
https://devcentral.f5.com/wiki/iRules.http__host.ashxHTTP::header
https://devcentral.f5.com/wiki/irules.http__header.ashxif there are multiple hostnames, you may store them in data group and search it using class command.
class
https://devcentral.f5.com/wiki/irules.class.ashx - nitass
Employee
I have URL xyz.abc.com now when client hits this URL ..F5 should insert http header with server name ,which server request should be forwarded .
do you want to manually select server and insert custom http header based on hostname in url (host header)?
or
do you want to rewrite http host header based on load balanced server?
this is an example of the latter one.
config root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm virtual bar ltm virtual bar { destination 172.28.24.10:80 ip-protocol tcp mask 255.255.255.255 pool foo profiles { http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 7 } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm pool foo ltm pool foo { members { 200.200.200.101:80 { address 200.200.200.101 } 200.200.200.111:80 { address 200.200.200.111 } } } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm data-group internal servername ltm data-group internal servername { records { 200.200.200.101/32 { data server101 } 200.200.200.111/32 { data server111 } } type ip } root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux ltm rule qux { when HTTP_REQUEST_SEND { clientside { HTTP::header replace Host [class lookup [LB::server addr] servername] } } } trace [root@ve11a:Active:In Sync] config ssldump -Aed -nni 0.0 port 80 New TCP connection 1: 172.28.24.1(38986) - 172.28.24.10(80) 1409877091.1710 (0.0015) C>S --------------------------------------------------------------- GET /attempt1 HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.24.10 Accept: */* --------------------------------------------------------------- New TCP connection 2: 200.200.200.14(38986) - 200.200.200.111(80) 1409877091.5871 (0.4142) C>S --------------------------------------------------------------- GET /attempt1 HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: server111 Accept: */* ---------------------------------------------------------------
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com