Serve static site on S3 + CloudFlare with Apache retaining the source URL

25 Views Asked by At

I have React app on S3 with CDN as CloudFlare(abc-apps.com). My main tomcat application is running on EC2 with Apache as a webserver fronted by ALB and DNS(abc.com) hosted on CloudFlare. Now I want my tomcat applications's domain with subpath abc.com/foo to redirect to the CDN(abc-apps.com) without replacing the URL in the browser and serve the content from S3 via CloudFlare.

To achieve that I have added the following to my Apache config:

  ProxyPass /foo https://abc-apps.com/a/b flushpackets=Off keepalive=Off timeout=600

  ProxyPassReverse /foo https://abc-apps.com/a/b

I have also tried with RewriteCond and RewriteRule, which works but, replaces the URL in the browser with https://abc-apps.com/a/b.

This is what it returns when the site abc.com/foo is hit with the current ProxyPass config in Apache.

enter image description here

I was able to achieve the expected result with CloudFront by adding abc.com as an "alternate domain" to CloudFront, but the same can't be done with CloudFlare

0

There are 0 best solutions below