How to Configure SSL in Lighttpd Server

How to Configure SSL in Lighttpd Server

How to Configure SSL in Lighttpd Server:

All the sites running with SSL are used https protocol on default port 443. SSL provides secure data communication by encrypting data between server and client. In our earlier articles we have described about installing lighttpd and creating virtualhosts in CentOS/RHEL systems. This article will help you to configure SSL in Lighttpd server. For this example we are using an self signed certificate.

If you are looking for configure ssl in Apache/HTTPD, then you have to this article.

Step 1: Create Certificate Signing Request (CSR)

For creating SSL certificate, the first requirement is to create private key and CSR. A CSR is an file which have all details about domain including an public key. first create a directory where to create csr and key.

# mkdir /etc/lighttpd/ssl/
# cd /etc/lighttpd/ssl/

Now create CSR and key file with following command. Change name of files and as per your domains. This command will ask for enter information about your domain. Read more about creating CSR.

# openssl req -new -newkey rsa:2048 -nodes -keyout -out
Generating a 2048 bit RSA private key
writing new private key to ''
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Delhi
Locality Name (eg, city) [Default City]:Delhi
Organization Name (eg, company) [Default Company Ltd]:LinuxMasters Inc.
Organizational Unit Name (eg, section) []:web
Common Name (eg, your name or your server's hostname) []
Email Address []

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: [Leave Blank]
An optional company name []: [Leave Blank]

Step 2: Request Certificate from CA

After creating CSR, Request an SSL certificate from any certificate providers like Geotrust, Comodo, Digicert or GoDaddy etc.

or create a self signed certificate for internal use. We do not recommend this for production sites.

# openssl x509 -req -days 365 -in -signkey -out

You will get created certificate file in current directory with name Now create pem file by combining key file and certificate in one file

# cat >

Step 3: Setup VirtualHost with SSL

Edit Lighttpd configuration file /etc/lighttpd/lighttpd.conf and add the following values.

$SERVER["socket"] == ":443" {
        ssl.engine = "enable"
        ssl.pemfile = "/etc/lighttpd/ssl/"
      # = "/etc/lighttpd/ssl/CA_issuing.crt" = ""
        server.document-root = "/sites/vhosts/"
        server.errorlog = "/var/log/lighttpd/"
        accesslog.filename = "/var/log/lighttpd/"

Step 4: Verify Configuration & Restart Lighttpd

Verify syntax of configuration file before starting lighttpd service.

# lighttpd -t -f /etc/lighttpd/lighttpd.conf

Syntax OK

If you found that all syntax is ok, lets restart service

# service lighttpd restart
Enjoyed this video?
How to Configure SSL in Lighttpd Server
"No Thanks. Please Close This Box!"