I am having issues with Nginx not working with multiple domains pointing to the same IP address. When accessing either domain, they both default to "catacombsfellowship.org.cnf". When accessing edmunddesoto.com, it acts as if it is catacombsfellowship.org and I get an SSL cert error where the cert is for catacombsfellowship.org.
When I run either domain by themselves, they work fine. However, they don't work seamlessly together. What am I doing wrong?
Examples:
File: edmunddesoto.com.cnf
server {
listen 80;
listen [::]:80;
server_name edmunddesoto.com default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name edmunddesoto.com default_server;
root /var/www/html/edmunddesoto.com/live;
index index.php index.html index.htm index.nginx-debian.html;
ssl_certificate /etc/ssl/certs/edmunddesoto.com.crt;
ssl_certificate_key /etc/ssl/private/edmunddesoto.com.key;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
File: catacombsfellowship.org.cnf
server {
listen 80;
listen [::]:80;
server_name catacombsfellowship.org default_server;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name catacombsfellowship.org default_server;
root /var/www/html/catacombsfellowship.org/live;
index index.php index.html index.htm index.nginx-debian.html;
ssl_certificate /etc/ssl/certs/catacombsfellowship.org.crt;
ssl_certificate_key /etc/ssl/private/catacombsfellowship.org.key;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Ok, I figured it out. The issue was somehow it was redirecting to the www.* domains and those were not set in the server_name directive. So, by adding the www.* to the server_name directive, it fixed it.