Advance advice in connection with Apache Virtual Hosts Files

I need to setup a new cert for a new domain on my linode VPS which has multiple domains on it right now using multiple Apache Virtual Host files. A few years ago I configured certs for a few of those domains but there were always problems …so now I’m asking in advance.

I note that when certbot runs and I ask for 443 redirection, it seems to create its own new apache virtual host file alongside of the existing one. Currently my existing one follows the standard pattern like this:

<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog {APACHE_LOG_DIR}/error.log CustomLog {APACHE_LOG_DIR}/access.log combined

(as described on this digitalocean page: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts )

In the past I have manually modified the virtual host file to get the redirect to 443 …following the pattern outlined on this page:
https://cwiki.apache.org/confluence/display/HTTPD/RedirectSSL

However even after reading the letsencrypt documentation and going through the forum I still don’t understand the whole process. Specifically:

  1. If I’m asking certbot (at the time of creation) to take care of the redirect, do I still need to do the changes to the virtual host file as outlined in the above-mentioned apache document? Should I be doing this before or after running the certbot tool?
  2. Since certbot creates a new virtual host file alongside the old one, do I still need the old one?

Thank you,
Patrick

1 Like

Hi Patrick,

Certbot should be able to take care of this for you, assuming you're using --apache. You shouldn't need to do it yourself in this case.

The new one that it creates is for port 443 (HTTPS). However, you still need the old one for port 80 (HTTP), at least to perform the redirection. If you delete the port 80 virtual host, visitors to your site on port 80 will get an error instead of being redirected to the HTTPS version.

1 Like

IT Worked !!! Super !
Thanks so much for the explanation Schoen!

Regards,
Patrick

2 Likes

Great! It’s always great to hear how well Certbot satisfies this use case. :slight_smile:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.