Mobile app version of vmapp.org
Login or Join
Chiappetta492

: Wordpress Reverse Proxy with Cloudfront and S3 I have an angular site / web application example.com hosted on Amazon S3 as a static website. This s3 bucket serves as the origin for a cloudfront

@Chiappetta492

Posted in: #AmazonCloudfront #AmazonS3 #Dns

I have an angular site / web application example.com hosted on Amazon S3 as a static website. This s3 bucket serves as the origin for a cloudfront distribution and it works perfectly.

We have an additional requirement of deploying a blog for SEO purposes. I have wordpress instance which I mapped using DNS to blog.example.com

How can I make this example.com/blog?

All the links on the blog must redirect to example.com/blog instead of blog.example.com
The address bar should always be displayed as example.com/blog All the guides I have gone through require the example.com to be
hosted via Nginx or Apache. This has to be on S3 + cloudfront.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Chiappetta492

1 Comments

Sorted by latest first Latest Oldest Best

 

@Welton855

Easy enough.

CloudFront supports multiple origin servers, and uses path patterns to determine which origin server to forward the requests to... so multiple, independent backend systems, even systems that aren't inside AWS, can all "own" one or more paths under a single hostname, with one of them being the default and owning all the paths not explicitly configured.

This is probably similar to what you have read about Nginx or Apache (and can also be done with HAProxy and others), but the request routing is done by CloudFront, which connects to the appropriate back-end, sends the request, and returns (and possibly caches) the response.

It does not redirect, so the browser address bar never changes.

The caveats:

CloudFront won't strip paths, so /blog* routes requests to bloghost.example.com then bloghost has to have its content under the /blog path, not in the root of the site.

CloudFront forwards very few headers to the origin by default. You can configure it to forward what you need, but every header you forward will reduce your cache hit ratio. There are very sound reasons why this is true, though beyond the scope of this answer. You need to identify which headers wordpress needs, and whitelist them in CloudFront.

You will also need to configure CloudFront to forward query strings and cookies, since, again, it doesn't forward those by default.

See also:
stackoverflow.com/a/38709097/1695906
serverfault.com/a/729706/153161
stackoverflow.com/a/32364600/1695906

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme