Forum Discussion
Change HTTP host to selected pool member IP address
Hi,
I have BIG-IP LTM 11.6 HF6 with public IP address and two WEB servers with private IP addresses in pool.
Problem is that WEB server expects it's private IP address in host field in HTTP header so I need to modify host filed to IP address od selected pool member.
I tried with few options, but nothing works.
For example:
when HTTP_REQUEST_SEND {
{
HTTP::header replace Host "[IP::server_addr]"
}
}
or
when HTTP_REQUEST_RELEASE {
HTTP::header replace Host "IP::server_addr"
}
On the other hand, if I put static IP in host header (just for one of pool members), things are working (just for that one server):
when HTTP_REQUEST_RELEASE {
HTTP::header replace Host "10.24.143.19"
}
Pls give me some advice.
BR, Mate
14 Replies
- Brad_Parker_139
Nacreous
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_Parker_139
Nacreous
Just 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_132781
Cirrostratus
Hi, 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_Piro2
Cumulonimbus
why did you try to change irule provided by Brad... his irule may work, your irule not.
- Brad_Parker
Cirrus
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_Parker
Cirrus
Just 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_132781
Cirrostratus
Hi, 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_Piro2
Cumulonimbus
why did you try to change irule provided by Brad... his irule may work, your irule not.
- Mate_132781
Cirrostratus
It's asking me for FastHTTP profile, and I have associated standard HTTP profile.
Is there any possibility to modify HTTP header after pool member is selected?
- Amanpreet_Singh
Cirrostratus
Hi Mate, HTTP_REQUEST_SEND or HTTP_REQUEST_RELEASE works after pool member selection.
- VernonWells
Employee
Regardless of the route domain id, the syntax is the same, namely:
HTTP::header replace Host [getfield [IP::server_addr] "%" 1]
divides the text stream into a series of field delimited by the identified character (%, in this case), and returns the field identified by number. So the "1", in this case, means "the first field". Since the IP will be something like 10.1.1.1%10, getfield with % will divide this into two fields, namely "10.1.1.1" and "10". You want the first field -- i.e., 10.1.1.1 -- hence the "1".getfield - Mate_132781
Cirrostratus
Thank you, at the end we solve this by modifying WEB application on WEB server.
BR, Mate
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