Pankaj
Pankaj

Reputation: 5250

Apache HTTPS Certbot LetsEncrypt issue

I am trying to set up a website with HTTPS on a Linode server. It's working on HTTP but not on HTTPS.

I tried to use Certbot to configure my domain for HTTPS.

root@mailer9:/etc/apache2/sites-enabled# sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: mailer9.com
2: www.mailer9.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 
Attempting to parse the version 0.29.1 renewal configuration file found at /etc/letsencrypt/renewal/mailer9.com.conf with version 0.28.0 of Certbot. This might not work.
Cert not yet due for renewal

You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/mailer9.com.conf)

What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for mailer9.com
http-01 challenge for www.mailer9.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mailer9.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mailer9.com-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Your existing certificate has been successfully renewed, and the new certificate
has been installed.

The new certificate covers the following domains: https://mailer9.com and
https://www.mailer9.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mailer9.com
https://www.ssllabs.com/ssltest/analyze.html?d=www.mailer9.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/mailer9.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/mailer9.com/privkey.pem
   Your cert will expire on 2019-04-02. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

root@mailer9:/etc/apache2/sites-enabled# 

It says that thing should be working fine but it's not working in HTTPS mode.

I see two VH files in sites-enabled directory.

root@mailer9:/etc/apache2/sites-enabled# cat mailer9.com.conf 
# domain: mailer9.com
# public: /var/www/html/mailer9.com/public_html/

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin [email protected]
  ServerName  mailer9.com
  ServerAlias www.mailer9.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/mailer9.com/public_html
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/mailer9.com/log/error.log
  CustomLog /var/www/html/mailer9.com/log/access.log combined

#RewriteEngine on
#RewriteCond %{SERVER_NAME} =mailer9.com [OR]
#RewriteCond %{SERVER_NAME} =www.mailer9.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

Another one for HTTPS, auto-generated by Certbot.

root@mailer9:/etc/apache2/sites-enabled# cat mailer9.com-le-ssl.conf 
<IfModule mod_ssl.c>
<VirtualHost *:443>
  # Admin email, Server Name (domain name), and any aliases
  ServerAdmin [email protected]
  ServerName  mailer9.com
  ServerAlias www.mailer9.com

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/mailer9.com/public_html
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/mailer9.com/log/error.log
  CustomLog /var/www/html/mailer9.com/log/access.log combined


SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mailer9.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mailer9.com/privkey.pem
</VirtualHost>
</IfModule>
root@mailer9:/etc/apache2/sites-enabled# 

However, if I visit http://mailer9.com/ then it works fine. But if I go to https://mailer9.com/ the page doesn't load. I am clueless about how to solve it, everything looks fine to me.

Apache modules command apachectl -M shows ssl_module is loaded.

Upvotes: 0

Views: 1589

Answers (1)

Pankaj
Pankaj

Reputation: 5250

It was caused because of ufw firewall. I added port 443 and it fixed it.

sudo ufw allow 443/tcp

Upvotes: 3

Related Questions