I need to redirect a website already up and running on a digital ocean server from http://www.example.com to https://www.example.com. I’ve been working on it all day and have been able to generate an ssl certificate from lets encrypt and have stored it in a specific file in my directory. I know I need to give the server the location of the certificate but I dont know where I have to type that in. I tried following a tutorial https://www.digicert.com/ssl-certificate-installation-ubuntu-server-with-apache2.htm but that doesnt seem to work either. On running a config test, I get an error saying that snakeoil.key (private key) file does not exist. Although when I sudo nano that file, I can see the key (it does exist!) I dont know what to do here anymore. Any help will be greatly appreciated. Thanks!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Okay, can you remove the HTTPS (443) VirtualHost, since it doesn’t work currently and it’s just Let’s Encrypt. And remove the redirect VirtualHost that I posted. Now your site should just work with HTTP (80).
Then go and follow this tutorial: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04
Can you post your VirtualHost configurations (both the one for port 80 and 443). It will be easier to help then.
Make sure your snakeoil.key file is readable by the same user/group as Apache, which is normally www-data
One way is to change your port 80 Virtualhost to this and restart Apache:
<VirtualHost *:80>
ServerName yourdomain.com
Alias www.yourdomain.com
Redirect permanent / https://www.yourdomain.com/
</VirtualHost>
In your_virtual_host.com.conf file put the following configuration:
<VirtualHost *:80>
ServerName <ip_or_host>
Redirect "/" "https://<ip_or_host>"
</VirtualHost>
<VirtualHost *:443>
ServerName <ip_or_host>
DocumentRoot /var/www/whateverfolder
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
<Directory /var/www/whateverfolder/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Some of the parameters have to be changed or commented out, depends on your previous configuration steps.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.