Originally written back in 2014, settings may have changed since then
Lighttpd is a great webserver software, and in this tutorial I'll be showing you how to setup SSL Encryption on Lighttpd with your own self-signed certificate. Please note, if your looking to setup SSL with a purchased certificate, please refer to this article, which better explains how to setup a site with SSL encryption with a trusted certificate. This tutorial is for a self-generated certificate, which means every time someone visits the site they'll get an error saying the site is not valid. But if your like me and your only doing development testing, then this makes more sense then buying a SSL Certificate for a site that is only for testing.
Step 1: Generate the keys and certificates. First, lets create a directory for them.
Now to generate both the key and certificate.
This command will use OpenSSL to generate the key and certificate pair. Once you run this command, you'll see OpenSSL begin the generation process. It will ask you for a"PEM Pass phrase". Enter a password you can easily remember. Now you will be asked questions about your location, organization, etc... Leave these default as we don't need them for a self signed certificate. Congratulations! Your key and certificate are now generated.
Now we need to "unlock" the key. We can do this by running the command below:
You'll be asked for your password that you typed in earlier above. Enter it, and your key should now be unlocked.
Now you have to convert the .key file and .crt file into a .pem file for lighttpd. This can be done by typing:
Make sure you move the keys to the directory we made earlier.This part is essential for getting lighttpd to work with ssl. You may already have them in the right spot, but just to be sure you can always go to "/etc/lighttpd/ssl" and type "ls" to be sure. Run the following commands to move the files if they're not there already:
Step 2: Configuring Lighttpd Now we need to setup the Lighttpd config file to accept SSL connections. Edit the file /etc/lighttpd/lighttpd.conf. Use your favorite text editor.
Scroll to the bottom of the file, and add the following lines:
Configure the above to fit your custom needs.
Step 3: Test and restart lighttpd
Now, test the config file for lighttpd by typing the command:
If you see the text"Syntax OK", then lighttpd is ready to go. If you did not see this message, please re-read the tutorial and make sure that everything was copied correctly. Now all you have to do is restart lighttpd, just type:
Congratulations! You can now visit your newly encrypted site!