Lighttpd Server with SSL
By Fahad Ahammed
- 2 minutes read - 290 wordsLighttpd is one of the speediest webserver which will make you feel like you got a highspeed internet connection with low price. However , i will explain you how to create ssl certificate and use it in lighttpd vhost for accessing particular websites with particular certificate.
Imagining you have your websites document root in /var/www/site1.com. you can create multiple sites with help of this article.
If you have used /var/www/site1.com as document root you will have created two folders web and logs in there where logs will keep all error logs and web will keep all your websites files. Now for ssl certificate you will need another folder named ssl.
Now create certificate and key.
You will be asked for some information. You will have to write your domain name in Common Name Section which you want as https or ssl like below.
Certificate creation is OK but if you want to get your self signed certificate valid for a long time you have to change above lines orange colored numbers. 1460 days means 4 years. If you want to get validity of that certificate of around 20 years you need to put there 7300 that means 365×20.
Now we will need to combine both key and crt file to act as one.
You can create pem file that means combined certificate by one command.
Now let us use that certificate in our sites vhost.
Edit /etc/lighttpd/site1.com.conf :
Make sure it looks like below :
Now save the file and restart lighttpd:
Now you can access your sites by ssl certificate or https.
If You want to redirect all http to https You have to add below lines on the configuration and restart lighttpd server.
Now restart and check the website.