1

I have apache2 running on ubuntu 14.04 and had set up SSL using Let's Encrypt.

On one of my domains (domainA) it works fine. I can reach it at

http://domainA.com http://www.domainA.com 

or

https://domainA.com https://www.domainA.com 

However I have additional domains point at the box and have setup virtual servers for each of these. I set them up in the same way I setup domainA (see this tutorial if you're wondering how)

On my additional domains traffic over https displays the right dummy content - but traffic over http just shows me the root directory (so the default index.html shows up).

in /etc/apache2/sites-available I have the following:

000-default.conf default-ssl.conf domainA.com.conf domainA.com-le-ssl.conf domainB.com.conf domainB.com-le-ssl.conf 

They are all setup identically with only the pertinent information changed.

domainA .conf looks like this:

<VirtualHost *:80> ServerAdmin [email protected] ServerName domainA.com ServerAlias www.domainA.com DocumentRoot /var/www/html/domainA/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

domainB.conf looks identical except with 'domainB' substituted instead of domainA. The domainA.com-le-ssl.conf file looks almost identical except for including all appropriate SSL files and being on port 443 (it's generated dynamically when I create the file with Let's Encrypt - I haven't touched them)

So domainB.conf looks like this:

<VirtualHost *:80 ServerAdmin [email protected] ServerName domainB.com ServerAlias www.domainB.com DocumentRoot /var/www/html/domainB/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

DomainB.com-le-ssl.conf looks like this (identical to DomainA with only pertinent names changed):

<IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin [email protected] ServerName domainB.com ServerAlias www.domainB.com DocumentRoot /var/www/html/domainB/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLCertificateFile /etc/letsencrypt/live/domainB.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/domainB.com/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf SSLCertificateChainFile /etc/letsencrypt/live/domainB.com/chain.pem </VirtualHost> </IfModule> 

http and https on domainA work with no issue, both showing the same thing.

http on domainB takes me to /var/www/html

https on domainB takes me to /var/www/html/domainB/public_html (as intended)

DNS is pointing to my server fine for the appropriate domains - so I don't think it's a DNS issue as much as an issue with the configs or maybe the SSL?

Just wondering as to why and/or how I can change that? Does anyone have any ideas why it might have worked on the first one but for none of the others?

I feel like it's picking up 000-default.conf for HTTP traffic.

My 000-default.conf looks like this:

<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 
2
  • Could you edit your post and add the configuration files for domainB (domainB.com.conf and domainB.com-le-ssl.conf)? Commented Dec 30, 2016 at 7:26
  • Done. Added the config files for DomainB per your request (although I figured out my issue listed in the answer below). Commented Jan 2, 2017 at 14:23

1 Answer 1

2

So apparently at some point the HTTP version of the sites had become disabled (potentially when enabling the HTTPS version).

Once I did the following they were working over both port 80 and port 443 (http and https respectively):

sudo a2ensite domainB.com.conf 

Then I would reload apache with this:

sudo service apache2 reload 

Then it would pickup the configuration for the HTTP version of the site and direct it appropriately.

I decided I wanted all traffic to be forced to use HTTPS - so I added the following line to the HTTP conf (/etc/apache2/sites-available/domainB.com.conf)

Redirect permanent / https://domainB.com 

Now if anyone tries to get to the site from HTTP it directs them to the appropriate spot.

Hope this helps someone else :)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.