Cloudflare proxy and X-Forwarded-Host header

Hi there,

I was wondering if Cloudflare sends to the proxied server the X-Forwarded-Host with the domain that originated the request. Or maybe it uses another header for the same purpose?

I looked on all the different headers sent and I couldn’t find it.

I hope someone can clarify this.

Thanks in advance,
Nico

2 Likes

There are two:

  • CF-Connecting-IP
  • X-Forwarded-For

Here’s the scoop:
https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-

Hi sdayman,

Thanks for replying, but both headers provides an IP, either the visitors or the Cloudflare proxy.

What I need is the host that has been requested, like X-Forwarded-Host.

Thanks again,
Nico

3 Likes

Hi,

I have a similar problem as well, where I need to get the host of the originating request.

Is this a feature that can be turned on with the service or is there no support for forwarding the host to the target?

4 Likes

Hello, is there a way to send the hostname of the original request, so a service like AWS Lambda can see the hostname? It would be great if x-forwarded-host were populated with the hostname of the request.

2 Likes

Had the same problem, I had to create a tiny reverse proxy in Cloudflare workers (router mode) to add that header.

Very strange they don’t provide it by default to be honest.

Since that time, Transform Rules has come around. It may be possible to copy http.host into your own request header:

1 Like