Using Page Rules to Re-Write Host Headers

The ability to rewrite Host Headers is now available in Page Rules. This feature is currently available for domains on the Enterprise plan.

A common use case for this functionality is when your content is hosted on an Amazon S3 bucket. Amazon has designed their system to only accept host headers that have the same name as the bucket hosting your content. In this way, a request to "Host: your-domain.com" must be re-written to “Host: your-bucket.s3.amazonaws.com", or else the request will be denied.

*Note: In some cases you can adjust your Amazon S3 Bucket to accept Host Headers that are not the bucket name.

To ensure the header is rewritten, simply go to Page Rules, specify the URI this rewrite will apply to, and write in the Host Header you want to change to. Do this in the "Host Header Override" text box. Any request matching the URI you have specified, will have the Host Header overridden to the one you have put in the "Host Header Override" box." Please see the example below:

Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk