HTTPS not working fully (CertBot)

Please show the certbot command line you ran.

all I did was run this:
certbot --apache
then I did the numbers of the sites I wanted (3, 4 in my case).
then for the redirect, I entered 2.

Try 3,4 then 1.
You already have the redirection taken care of.
[whichever number doesn’t ask it to add redirection for you]

Then show the error message, if any.
[however insignificant the message may seem - please include all shown]

Still doesn’t work.
But the log looks normal.

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: asite.com
2: www.asite.com
3: mainsite.com
4: www.mainsite.com


Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter ‘c’ to cancel): 3, 4
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/mainsite.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): 1
Keeping the existing certificate
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mainsite.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mainsite.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


Congratulations! You have successfully enabled https://mainsite.com and
https://www.mainsite.com

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


IMPORTANT NOTES:

  • Congratulations! Your certificate and chain have been saved at:
    /etc/letsencrypt/live/mainsite.com/fullchain.pem
    Your key file has been saved at:
    /etc/letsencrypt/live/mainsite.com/privkey.pem
    Your cert will expire on 2019-05-20. 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

Please explain:

I see:

Please also show:

And ensure you have restarted/reloaded apache.

I go on www.mysite.com or mysite.com, it still comes up as not secure.
but when I go to https://mysite.com, it says it is secure.

OK then the problem is with the redirection only.
The cert is working fine and the site is secured.

Let’s have a look at…
grep -Eri 'servern|servera|listen|virtualh|rewrite' /etc/apache2/sites-enabled/

Nothing comes up on the terminal.

ensure you run it as root:
sudo grep …

Show:
ls -l /etc | grep apache
find / -name apache2.conf

root@Ubuntu-1804-bionic-64-minimal /etc/apache2/sites-available # find / -name apache2.conf
/etc/apache2/apache2.conf
/opt/eff.org/certbot/venv/lib/python2.7/site-packages/certbot_apache/tests/testdata/debian_apache_2_4/augeas_vhosts/apache2/apache2.conf
/opt/eff.org/certbot/venv/lib/python2.7/site-packages/certbot_apache/tests/testdata/debian_apache_2_4/default_vhost/apache2/apache2.conf
/opt/eff.org/certbot/venv/lib/python2.7/site-packages/certbot_apache/tests/testdata/debian_apache_2_4/multiple_vhosts/apache2/apache2.conf
/opt/eff.org/certbot/venv/lib/python2.7/site-packages/certbot_apache/tests/testdata/debian_apache_2_4/multi_vhosts/apache2/apache2.conf
/opt/eff.org/certbot/venv/lib/python2.7/site-packages/certbot_apache/tests/testdata/complex_parsing/apache2.conf

grep -i include /etc/apache2/apache2.conf

root@Ubuntu-1804-bionic-64-minimal /etc/apache2/sites-available # grep -i include /etc/apache2/apache2.conf
# * ports.conf is always included from the main configuration file. It is
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
# Include of directories ignores editors’ and dpkg’s backup files,
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

ls -l /etc/apache2/sites-enabled/*.conf

root@Ubuntu-1804-bionic-64-minimal /etc/apache2/sites-available # ls -l /etc/apache2/sites-enabled/*.conf
lrwxrwxrwx 1 root root 37 Feb 4 08:14 /etc/apache2/sites-enabled/othersite.com.conf -> …/sites-available/othersite.com.conf
lrwxrwxrwx 1 root root 41 Feb 4 08:07 /etc/apache2/sites-enabled/mainsite.com.conf -> …/sites-available/mainsite.com.conf
lrwxrwxrwx 1 root root 58 Feb 19 02:44 /etc/apache2/sites-enabled/mainsite.com-le-ssl.conf -> /etc/apache2/sites-available/mainsite.com-le-ssl.conf
lrwxrwxrwx 1 root root 29 Feb 3 05:51 /etc/apache2/sites-enabled/phpbb.conf -> …/sites-available/phpbb.conf
lrwxrwxrwx 1 root root 46 Feb 19 02:44 /etc/apache2/sites-enabled/phpbb-le-ssl.conf -> /etc/apache2/sites-available/phpbb-le-ssl.conf

grep -Ei 'servern|servera|listen|virtualh|rewrite' /etc/apache2/sites-available/othersite.com.conf
grep -Ei 'servern|servera|listen|virtualh|rewrite' /etc/apache2/sites-available/mainsite.com.conf
grep -Ei 'servern|servera|listen|virtualh|rewrite' /etc/apache2/sites-available/phpbb.conf

mainsite.com.conf
<VirtualHost :80>
ServerAdmin webmaster@localhost
ServerName mainsite.com
ServerAlias www.mainsite.com
RewriteEngine On
RewriteRule ^.well-known/acme-challenge/ - [L]
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.
) https://%{SERVER_NAME}/$1 [R,L]

othersite.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName othersite.com
ServerAlias www.othersite.com

phpbb.conf
<VirtualHost *:80>
ServerAdmin admin@ubuntu
ServerName mainsite.com
ServerAlias ubuntu
RewriteEngine on
RewriteCond %{SERVER_NAME} =mainsite.com [OR]
RewriteCond %{SERVER_NAME} =ubuntu
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

<VirtualHost *:80>
ServerAdmin admin@ubuntu
ServerName othersite.com
ServerAlias ubuntudbz
RewriteEngine on
RewriteCond %{SERVER_NAME} =othersite.com [OR]
RewriteCond %{SERVER_NAME} =ubuntudbz
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Two conflicts found:

mainsite.com.conf
ServerName mainsite.com <<<<<<<<<<<<<<<<<<<<<<<< #1

othersite.com.conf
ServerName othersite.com <<<<<<<<<<<<<<<<<<<<<<<< #2

phpbb.conf
ServerName mainsite.com <<<<<<<<<<<<<<<<<<<<<<<< #1
ServerName othersite.com <<<<<<<<<<<<<<<<<<<<<<<< #2

othersite.com shouldn’t have any involvement though.
It’s a completely different site that I haven’t put a cert for.

conflicts are conflicts - you will have to address them all at some point.

Regardless the mainsite.com is at issue here and now.

I have deleted the phpbb.conf and still no difference.
(Yes, Apache2 has been restarted.)