12

I'm trying to switch from AWS CloudFront to CloudFlare.

Currently, my web site is hosted on EC2 and my large static files are placed in S3 separately. CloudFront let me serve the web pages and the static files with the same domain, proxying the accesses to the corresponding location (origin) based on path patterns. i.e.

  • http://example.com/files/* => S3
  • http://example.com/* => EC2

In CloudFlare, I only found URL forwarding/redirects, which returns a 301/302 redirection to the visitor instead of serving the content directly. Is it possible to avoid the 301/302 redirect, but "mask" the origin location like CloudFront does?

I need to avoid the 301/302 redirect since a custom client application will access the static files, but the application does not support http redirection (yes, I know it's silly).

2 Answers 2

11

This is something that they recently started offering as an enterprise feature see: https://support.cloudflare.com/hc/en-us/articles/206190798-Using-Resolve-Override-in-Page-Rules

3

You could use cloudflare workers: https://developers.cloudflare.com/workers/recipes/conditional-routing/

For your use case you could use the provided example, but change the logic to inspect the url path instead of an http header.

1
  • 1
    Welcome to ProWebmasters SE. :) Can you add a snippet of the "logic" code so that it's easier to understand what you mean? (thanks!)
    – elbrant
    Commented Jan 30, 2019 at 2:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.