X-Forwarded-Host Header should show Original Host?

  1. Hey all, I’m hoping to get some help using Workers as a transparent reverse proxy for one of my SAAS apps. The flow is:
- User visits example.com/path/[adfada] which is a mapped to a worker @ example.com/path/*
- The worker proxies the request without modification to backend.com/path/[adfada]
- Worker returns the response back to the user

So far, I have this all working without an issue. However, my backend actually expects to see either a Host header or X-Forwarded-Host header of example.com . Currently, examining the request headers, my backend sees both Host and X-Forwarded-Host as backend.com . My understanding of the Host header suggests that this behavior is understandable and acceptable. However, X-Forwarded-Host should actually reflect the “original host requested by the client”, which in this case should be example.com ? I’m having a little trouble understanding why both Host and X-Forwarded-Host are both set to the backend.

Additionally, I have tried modifying the request headers directly, trying to manually set both the Host and X-Forwarded-Host headers, but it seems that those are perhaps immutable? I’ve tried modifying both via Workers code ( header.set() ) as well as Transform Rules, but neither seem to have any impact.