Hacker News new | ask | show | jobs
by thitcanh 1888 days ago
Just as a side-note since their example uses CloudFlare: I think that host-rewriting is disabled on CloudFlare as a security or spam-avoidance feature.

If you want to have CF change the host to something else, like censored.com, this domain must also be part of your controlled domains, which means CF can’t be used for this purpose.

This at least was the case last time I looked into this (12 months ago)

It’s also possible that this feature is enabled for paying users, which I wasn’t.

2 comments

You can do it with a Worker, it'll do completely independent requests to the backend and you can then rewrite them (e.g. change headers, content) and relay them to the client.
I did just this, to create a version of Github with scrambled text.

https://guthib.mattbasta.workers.dev/

I found this to be the case on CloudFront as well. As far as I can tell, it's not possible to direct the request to a different, custom origin based on the Host header. Only the URL path.

The recommendation is to use a Lambda@Edge worker to do it. I find this very annoying.

Some low-cost CDNs allow this, like BelugaCDN and BunnyCDN, probably others, with a web GUI for setup.