Forum Discussion
Brad_Parker
Nov 18, 2015Cirrus
Try it in the SERVER_CONNECTED event. It won't work on the first request until an LB decision has been made.
when SERVER_CONNECTED {
HTTP::header replace Host [LB::server addr]
}
Updated Just noticed you are trying to use HTTP_REQUEST_SEND, that should work. Are you using route domains? If so you will have to parse out the %rd. The getfield command will take the first field from the host header with "%" being the delimiter. If using route domains IP variables will be returned as x.x.x.x%rd. The below will work for ANY route domain by stripping off the %rd. You will be left with x.x.x.x. Get field has a start index of 1, that's why the number 1 is used. https://devcentral.f5.com/wiki/iRules.getfield.ashx
when HTTP_REQUEST_SEND {
HTTP::header replace Host [getfield [IP::server_addr] "%" 1]
}
- Brad_ParkerNov 18, 2015CirrusJust noticed you are trying to use REQUEST_SEND, that should work. Are you using route domains? If so you will have to parse out the %rd. when HTTP_REQUEST_SEND { HTTP::header replace Host [getfield [IP::server_addr] "%" 1] }
- Mate_132781Nov 19, 2015CirrostratusHi, great hint. Yes, we are using Route Domains and partitions. Route domain 10 id default route domain for partition uder which nodes, pools VS and iRules are created. I tred syntax you sent, but still it's not working. when HTTP_REQUEST_SEND { HTTP::header replace Host [getfield [IP::server_addr] "%"10] }
- Stanislas_Piro2Nov 19, 2015Cumulonimbuswhy did you try to change irule provided by Brad... his irule may work, your irule not.
- Brad_ParkerNov 19, 2015CirrusUpdated my original answer. your rule will not work because [getfield [IP::server_addr] "%"10] will return the 10th field(which doesn't exist). [getfield [IP::server_addr] "%" 1] as I state in the updated answer will return the first field of x.x.x.x%10 leaving you with just x.x.x.x