Hosting two Webflow sites on the same domain with the second site in a subfolder

Hello @Jake_Ruth

I have been trying to setup reverse proxy setup through cloudfront

I want to access both my webflow and wordpress sites through single domain, Let’s say www.domain.com

I want www.domain.com/blog to be connected to my wordpress site
and www.domain.com to be connected to webflow site

www.webflowdomain.com → Which is already hosted in webflow
www.wordpressdomain.com → which is hosted on wordpress

I followed below article and configured through cloudflare workers, it is working fine in this case

However when I am trying to configure the same behavior through cloudfront origins and behaviors I am getting 502 bad gateway errors

Could you please help me how to set it up?

In cloudfront, I have added 2 origins and corresponding behaviours
www.webflowdomain.com → * Default pattern
www.wordpressdomain.com → /blog/*

I am having different thoughts here

1.How come cloudflare setup is working fine while cloudfront is not working?
2.Do we need to setup any certificates to get this worked? or any other steps I am missing here

Thank you

Hi, I encountered the same issue but managed to solve it, so I thought I’d share my approach.

To implement this, you’ll need an NGINX server for reverse proxying.

First, set up a fallback to a subdomain proxied by Webflow, as mentioned by others. This step is fairly straightforward.

The more complex part involves handling regex rules for the /blog subdomain.

Let’s say you have a subdomain like blog.example.com, and you want everything with the /blog prefix to be directed there. Here’s the setup:

All asset files should have the /blog prefix. This allows NGINX to match the /blog regex in the rule and route traffic to the proxy server.

However, you must manage URL paths under /blog carefully. For example, if you want /blog-post1 to route to /blog/blog-post1 and ultimately fallback to /blog/blog-post1/index.html, you can’t achieve that in one step.

You’ll need a general rule like this:

try_files $uri $uri/index.html @proxy;

(The @proxy points to the blog.example.com subdomain.)

If anything with the /blog prefix matches, traffic will be routed to the subdomain, including the asset files with the /blog prefix. However, be sure to exclude files already in the subdomain from being redirected again. Also, when serving from the subdomain, the routing path should not include /blog, or it will lead to 404 errors. Attempting to append /index.html can create an endless loop, causing a 500 error.

In short, there are two scenarios to handle:

  1. For browser URL routing, remove the /blog prefix and route to the subdomain.
  2. For asset routing, serve them directly from the subdomain.

Hope this helps!