Forum Discussion

John_45559's avatar
John_45559
Icon for Nimbostratus rankNimbostratus
Jun 15, 2010

Manipulating host: XXX.XXX.XXX in http POST header

I need to change the host:xxx.xxx.xxx field to the endpoint on a http request. I have been attempting to look at the wiki for syntax but I am forced to use IE6 which crashes every time I access IRules wiki. Also I am new at this.

 

 

Basiclly we are sending soap envelopes to vip on the F5 (9.4.3). The http post does get sent to the pool member or endpoint. The endpoint responds with a 302 redirect to the endpoint ip. I suspect this is due to Apache ReWriteRules and the host:xxx.xxx.xxx field has the virtual ip of the F5 and needs to be the IP of the member (or destination of the member of the pool). This is a third party solution so we can't jack with that end, and don't want a redirect since the 302 indicates the destination intended in the 1st place.

 

 

So we have a vip with pool with 2 endpoints- I would like to modify host field to reflect the active pool member of the http request. I am in a lab enviroment so this would only be a test. I think this would be similar to IRule redirect samples, I have looked at but I would like to change the host field to the active pool member to avoid the redirect. Maybe there is a better method of doing this.

 

 

POST /who/what/ProvisioningServic HTTP/1.1

 

Accept-Encoding: gzip,deflate

 

Content-Type: text/xml;charset=UTF-8

 

SOAPAction: ""

 

User-Agent: Jakarta Commons-HttpClient/3.1

 

Host: x.x.x.x <----- reflects F5 vip ip - needs to change to active member in pool

 

Content-Length: 780

 

 

 

 

 

I hope I explained this correctly and thanks for any responses.

 

 

 

2 Replies

  • If I am understanding what you need correctly this should get you started.

     

     

    This should capture the "bad ip address" that is being sent in the redirect and allow you to replace it with a specific ip address "good.ip.address.or.url". You will have to hard code it using this example, but if it does what you need then you can modify it further to be more dynamic.

     

     
    when HTTP_RESPONSE {
    if { [HTTP::is_redirect] and [HTTP::header Location] contains "bad.ip.address" } {
            HTTP::header replace Location [string map -nocase {bad.ip.address good.ip.address.or.url} [HTTP::header value Location]]
    }
    }
    
  • Actually the redirect has the correct IP. Let's say I am posting to 1.1.1.1/here/there which in this case 1.1.1.1 ip is the vip ip on the F5. When the post is sent to (endpoint) 2.2.2.2/here/there. the 302 found response indicates the document has moved to 2.2.2.2/here/there. In the post the HOST field retains the VIP IP which I think is causing the redirect.

     

     

    client -> F5 vip (1.1.1.1/here/there)

     

     

    F5 vip -> pool member (which is 2.2.2.2/here/there ) host field in header is 1.1.1.1

     

     

    pool member -> F5 (302 found redirect to 2.2.2.2/here/there ) etc....

     

     

     

    I would like to avoid the redirect if possible but again I might be barking up the wrong tree..

     

     

    thanks for the response - I will take a look at this.