I have added some code, so that the host name is extracted from the netty http transport server, in case it is not supplied with the Host header (which has been introduced in HTTP 1.1 and is never set in HTTP 1.0 if I am not completely mistaken out of my mind).

Regarding Simons comment about the security risk: I think the opposite is the case. In case you are using a proxy in front of elasticsearch (i.e. nginx or apache), you actually have to use the Host: header instead of the local hostname in order to not return some internal ip address instead of the external URL. Also using client data and reusing it is IMO not a security problem in this case.