EasyEngine + Multiple Domains Pointed at a Singe Wordpress Instance Not Quite Working

Hello Everyone,

I just spun up my first EasyEngine WordPress instance yesterday and have been mostly enjoying it so far. I did run into an issue though. The site I migrated to it has multiple domains pointed at a single wordpress instance. On the previous LEMP host I created manually, I didn’t have any issue resolving these to my host and then generating certs for them with CertBot. When I create a domain entry with EE, it creates a number of .conf files and directories that shouldn’t be necessary when pointing to a single instance. However, the domain names will resolve to my Wordpress instance (with an invalid certificate warning- which is to be expected) until I again use EE update to install a cert with LetsEncrypt. The moment the cert installs, I get a 403 NginX error. I’m sure this has something to do with how everything is pointed between the .conf files. I’d really like to stay within the framework of EE for as much as I can, but I’m wondering - is there any way that doesn’t involve a lot of back tracking to accomplish this?

Thanks in advance!

Ben

Are you wanting to redirect the other domains to the one domain where Wordpress is hosted?

1 Like

Hi Marty,

Thanks for responding! I don’t want it to redirect, per se, I just want a number of domains to resolve to the same Wordpress instance over SSL generated by LetsEncrypt. Wordpress is already configured to handle requests for multiple domains and the A records are pointed at it. Normally, pointing the A records is all that I’d have to do to get it to resolve. To me, the fact that it kind of works with an SSL warning until I EE install LetsEncrypt and the then 403 happens afterwards, has me convinced EE is adding some entries that are pointed at the root html folder it creates when you add the domain. The SSL warning is because I’ve got http redirecting to https so that part makes sense. I’ve tried adding some block entries in the nginx.conf and editing the .conf files in sites-available without any luck. Something else is pointing it to the empty default directory, just can’t figure out where it’s set. Any ideas would be appreciated.

Thanks again!

Ben

To explain this a little better: the end goal is to have domain[dot]com, domain[dot]co[dot]uk, domain[dot]co[dot]nz, etc, all resolve to the same WordPress instance. Normally, this is pretty easy to setup - I just add block entries that specify the domains, install letsencrpt and cerbot, then certbot finds the block entries and creates SSL certs for each of the domains and places them all in the same certificate directory. The problem is that when you create a domain with EE, it creates empty directories in anticipation of another Wordpress instance. In my case, I only want to have the one instance which all of the domains resolve to. When you EE install LetsEncrypt, it adds an ssl.conf file for each site you’ve added in the empty directory without WP (/var/www/ayrne.co.nz/conf/nginx/ssl.conf, for example) and places the cert as if it’s going to be pulled by a separate site in a separate directory. It also creates entries for each site in sites-enabled and redirects to them. This breaks resolution to the WP instance I want to resolve to. Also, when I point any of the .conf files in sites-enabled to the root wordpress directory of the actual WordPress instance, it pulls the cert for the .com instead of the .co.uk, or .co.nz (for example). Just wondering if there’s some right way to setup this scenario using EE.

Here’s what I’m running in EE:

  • ee site create somesite[dot]co[dot]uk #to create the site without any peripheral apps
  • ee site update ayrne.[dot]co[dot]uk --letsencrypt #to add letsencrypt

OK. ee tries to make life easy by doing everything with includes, which is great, but it can trip you up as soon as you want to do anything unusual.

ee sets the document root in the main conf (i.e. /etc/nginx/sites-available/example.com) for each domain, e.g.

root /var/www/example.com/htdocs

When you add the LetsEncrypt certificate it creates a couple of include files - /etc/nginx/conf.d/force-ssl-example.com.conf to handle the redirects, and /var/www/example.com/conf/nginx/ssl.conf to handle the ssl. Those shouldn’t be a problem unless you weren’t expecting them and are trying to do other redirects in the main conf?

Maybe it would help to put a test file in each domains htdocs and just prove the certificates are all working first, then try changing the root?

Also might be worth looking at how the multiple domain handling works in Wordpress - is this a plugin? - maybe it’s trying to apply Apache rules?

I’m guessing here :slight_smile: I’ve not used this kind of setup before.

1 Like

(post withdrawn by author, will be automatically deleted in 2 hours unless flagged)

Hello again Marty,

Just ran some test and it does indeed work from the root directory for each domain.

So it looks like I just need to pick the right .conf to point to the .com root. We’re getting closer.

Cheers!

Ben

Hey everyone, first, I want to apologize to anyone who felt I was ‘promoting’ anything. I was just pasting from my site and wasn’t trying to flaunt my website or anything similar - just doing things quickly and not thinking about how those links would be perceived. So to recap:

My goal was to have domain[dot]com, domain[dot]co[dot]uk, domain[dot]co[dot]nz, etc, all resolve to the same WordPress instance. Normally, this is pretty easy to setup - I just add block entries that specify the domains, install letsencrpt and cerbot, then certbot finds the block entries and creates SSL certs for each of the domains and places them all in the same certificate directory. The problem is that when you create a domain with EE, it creates empty directories in anticipation of another Wordpress instance. In my case, I only want to have the one instance which all of the domains resolve to. When you EE install LetsEncrypt, it adds an ssl.conf file for each site you’ve added in the empty directory without WP (/var/www/ayrne.co.nz/conf/nginx/ssl.conf, for example) and places the cert as if it’s going to be pulled by a separate site in a separate directory. It also creates entries for each site in sites-enabled and redirects to them. This breaks resolution to the WP instance I want to resolve to. Also, when I point any of the .conf files in sites-enabled to the root wordpress directory of the actual WordPress instance, it pulls the cert for the .com instead of the .co.uk, or .co.nz (for example). Just wondering if there’s some right way to setup this scenario using EE.

Here’s what I’m running in EE:

  • ee site create somesite[dot]co[dot]uk #to create the site without any peripheral apps
  • ee site update somesite[dot]co[dot]uk --letsencrypt #to add letsencrypt

The awesome news is - I found the solution! This can be done in a way that’s fairly intuitive, but the big thing is the KIND of site you create with EE. If you create a blank site via ee site create somesite, it will set the conf to resolve to HTML and you’ll get a 403, of course, it’s the same with ee site create somesite --html, but if you create it with:

  • ee site create somesite --php
  • ee site create somesite --letsencrypt

In short, it was resolving to the active sites root domain, but because ee site create somesite appears to create configuration for HTML, NginX was looking for an index.html and throwing a 403 error. Creating it with config for php fixed the issue immediately and allowed NginX to pull the index.php in the active WP install.

The only thing that needs to be done after creating the site and setting up LE is to point to the root of the actual wordpress instance you want to resolve to from the whateversite.conf in sites-available and everything will work perfectly!

Anyway, thought I’d share that.

Cheers!

2 Likes

@ayrne the forum software we use has some automated means to flag some behavior patterns. Unfortunately, it flagged you incorrectly. I removed flag from your post.

Feel free to add links back if you feel need for it. I apologize for inconvenience it caused to you.

2 Likes

@ayrne Thanks for sharing that and explaining it more here: https://ayrne.co.nz/how-to-resolve-multiple-domains-to-a-single-wordpress-instance-with-easyengine/

@rahul286 Can we please add a feature to EasyEngine to accomplish this that could look like this:

ee site create domain1.com domain2.com domain3.com … -wp (and of course -wpsubdom)

Thanks!

1 Like

Thanks Rahul!

After reading through this thread, I am still not sure what you did to get this working. I am in a similar boat. I have TWO domains that I wish to point to ONE install.

Question:

  1. Did you have to use the “ee site create” command for EACH domain separately (even though all files should be in the same place for all domains)?

Not sure why this is so difficult, this seems like a very common scenario…in fact, why can’t we just add the server name in the nginx conf? Will that mess up all ee commands going forward?

1 Like

I prefer to have the ability to implement separate conf blocks under separate domains, it keeps things less sloppy and more organized.

Here’s what you do to implement it this way:

Create your initial site. Then, to add another that uses the same root directory run:

ee site create second-site.com --php

Note: it has to be --php so that the index.php file Wordpress creates is looked for by NginX - otherwise it will look for an index.html. Now just go to the .conf for the domain you just added - /etc/nginx/sites-available/second-site.com, open it and edit this line from:

root /var/www/second-site.com/htdocs;

And change it to:

root /var/www/first-site.com/htdocs;

Restart NginX for the changes to take effect and you’re done. It takes less than a minute and is super easy to do. IMO, far quicker and more maintainable than hacking the default conf file.

1 Like

Thanks!

1 Like

Any time! =)