Roots Discourse

Configuration and provisioning for sub-directory setup using Bedrock + Trellis

Hey guys,

so I currently have the following issue. Website 1 has a transparent proxy configured for a subdirectory example1.com/blog. This is proxying the requests to example2.com, a wp bedrock website.

I want example2.com to handle the requests for example1.com/blog and also redirect users from example2.com to example1.com/blog.

So far I’ve changed the wp config file for the environment in bedrock (site/config/environments/production.php) for wp_home, wpsiteurl and wp_content_url to have the new URL.

Right now I can see the homepage of example2.com displayed under example1.com/blog with adjusted permalinks and most assets load properly. But the login page via /wp/wp-admin is giving me a 404 and certain files in the wp/wp-includes folder are also causing 404s.

I’m pretty sure I’m missing something substantial in the nginx configuration, because the /wp location seems to be causing the issues here. Not really sure where to look next though and I’m not too familiar with the nginx location directive to figure it out at this point.

Would greatly appreciate some pointers of where to look next, or maybe someone has completed a similar setup before?

Ok, so I’ve implemented a solution a couple of days ago. Not sure if it is the cleanest, but maybe still helpful to someone in a similar situation.

Compared to a setup without a transparent proxy I had to adjust the following files:

site/config/environments/production.php

roles/wordpress-setup/templates/wordpress-site.conf.j2

  • change the location configured from / to /blog in 3 places (lines 163, 260, 288)
  • The webserver was provisioned and running in production for example2.com, but is now also receiving proxied requests with a header set to example1.com. For everything to work properly, I had to add 2 new server blocks, so that the nginx server is now answering for both hosts (example1.com and example2.com). So basically add an if statement for production that sets the server_name to example1.com. And another if statement for production to add 2 server blocks (http and https) that only redirect example2.com to example1.com/blog.

roles/deploy/hooks/finalize-after.yml

  • For everything like login and assets to work properly, I had to symlink the web directory, within itself as blog, really not sure about this part
  • I added this to roles/deploy/hooks/finalize-after.yml so it’s done after every deployment.