Hi, due to some redirection issues on the target website, I would like to set the Host header with a different subdomain than the one we’re actually connecting to. Exactly what you would do with:
I’ve tried setting it in the redirection rule but it doesn’t seem to work according to the server logs:
[[redirects]]
from = "/*"
to = "https://website-old.xyz.com/:splat"
status = 200
force = false # COMMENT: ensure that we always redirect
headers = {X-From = "Netlify", Host = "www.xyz.com"}
Can you please help me understand if this is just totally unsupported or if there’s any other way I could do it?
Thanks for the reply @Scott. If I understand correctly, I can use the _headers to adjust the response headers from Netlify. In this case, I’m not looking to set response headers. Instead, I would like the proxied request to include a different Hostrequest header. That is, the HTTP connection is established using the resolved IP from website-old.xyz.com, but the Host header will be www.xyz.com.
Btw, the proxied request is not to a Netlify host but to another server we have with an old implementation of the website
Yes I did and I see how to send custom headers but not set the Host header, a service I am using needs to see the host header have the same domain as my websites domain. When using a reverse proxy in Netlify, the host header becomes Netlify and doesn’t work to load the content from the 3rd party service.
Sorry for the disconnect - yes, I can confirm that you CANNOT set the Host header to a custom value when we proxy. It will ALWAYS be set to the hostname we connect to (the one specified in your proxy rule), since most web services (including Netlify when it is proxied to) require this to function correctly.
I realize this is an old thread. But I wanted to check in whether anything has changed at Netlify since Feb 2021. Specifically looking at the original question, nunomluz was looking for a way to rewrite the Host header while proxying a request through Netlify [[redirects]]. I have a need to do the same, and I would want to handle it on the Edge because it is higher volume traffic.