Problems with Virtual Domains and Let's Encrypt
by Arty Ziff from LinuxQuestions.org on (#50DWF)
I recently burned down and rebuilt my server. I run CentOS v7. I used several Digital Ocean tutorials, including the LAMP and Virtual Domains tutorial:
https://www.digitalocean.com/communi...ts-on-centos-7
Everything seemed to be as it should, navigating to a domain brought me to the standard Apache "Testing" page. When I placed an index.html file in the public_html directory, I saw what I expected.
Next, I used Certbot to install Let's Encrypt certs. This is where things went an odd direction.
Apperently, my server account is tied to MyDomain.NET. All my virtual domains resolve correctly to their appropriate directories. But MyDomain.COM resolves to MyDomain.NET.
Here are the two relevant files:
mydomain.com-le-ssl.conf
Code:<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/html/mydomain.com/public_html
ErrorLog /var/www/html/mydomain.com/log/error.log
CustomLog /var/www/html/mydomain.com/log/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/chain.pem
</VirtualHost>
</IfModule>And...
domain.com.conf
Code:<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/html/mydomain.com/public_html
ErrorLog /var/www/html/mydomain.com/log/error.log
CustomLog /var/www/html/mydomain.com/log/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>Since I have no site defined for MyDomain.NET, when I navigate to MyDomain.COM, I see the Apache "Testing" page.
What's going on?


https://www.digitalocean.com/communi...ts-on-centos-7
Everything seemed to be as it should, navigating to a domain brought me to the standard Apache "Testing" page. When I placed an index.html file in the public_html directory, I saw what I expected.
Next, I used Certbot to install Let's Encrypt certs. This is where things went an odd direction.
Apperently, my server account is tied to MyDomain.NET. All my virtual domains resolve correctly to their appropriate directories. But MyDomain.COM resolves to MyDomain.NET.
Here are the two relevant files:
mydomain.com-le-ssl.conf
Code:<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/html/mydomain.com/public_html
ErrorLog /var/www/html/mydomain.com/log/error.log
CustomLog /var/www/html/mydomain.com/log/requests.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mydomain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/mydomain.com/chain.pem
</VirtualHost>
</IfModule>And...
domain.com.conf
Code:<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
DocumentRoot /var/www/html/mydomain.com/public_html
ErrorLog /var/www/html/mydomain.com/log/error.log
CustomLog /var/www/html/mydomain.com/log/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>Since I have no site defined for MyDomain.NET, when I navigate to MyDomain.COM, I see the Apache "Testing" page.
What's going on?