Good find! I think the two Nginx conf files could likely be the cause.
DNS looks fine, but try removing one Nginx conf:
- SSH in
- remove the non-www conf
(remove /etc/nginx/sites-enabled/mydomain.com.conf
)
- reload nginx
- try loading your site in the browser.
Below is a bunch of speculation about what could be going on due to the presence of the two confs.
Site key determines name for www_root, Nginx conf, and DB
I’m guessing you originally had this:
wordpress_sites:
mydomain.com:
...
The above creates the mydomain.com.conf
and a DB named mydomain_com_production
.
Then you probably made this change to the “site key”:
wordpress_sites:
- mydomain.com:
+ www.mydomain.com:
...
The above site key change creates the www.mydomain.com.conf
.
In addition, now you have two site directories in your www_root
:
/srv/www
├── mydomain.com
└── www.mydomain.conf
You would also have two databases due to the different site keys.
Nginx matches only one server
block per server_name www.mydomain.com
Line 7 in both your nginx confs: server_name www.mydomain.com;
Nginx will only match one or the other server
blocks with identical server_name
directives. Nginx probably matches the server
block in the conf file whose name comes first lexicographically.
The mydomain.com.conf
comes before www.mydomain.com.conf
alphabetically, so its OLD server
block is probably matched. This block has line 12 root /srv/www/mydomain.com/current/web;
so traffic is sent to your OLD deploy’s files where maybe the canonical host and env var was mydomain.com
and WP was perhaps redirecting www.mydomain.com
to mydomain.com
.
If that is the case, any new provision/deploy affects only the NEW site files in /srv/www/www.mydomain.com
but Nginx never sends traffic there.