SSL with Lighttpd

Use SSL encryption on your Lighttpd webserver.

Lighttpd installation
Lighttpd needs to be configured and compiled with SSL enabled:

./configure --with-openssl
make
make install

After lighty has been installed, you can confirm that it has been compiled with ssl enabled:

lighttpd -v

SSL Configuration

mkdir /root/.lighttpdssl
cd /root/.lighttpdssl
openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 365 -nodes
chmod 400 lighttpd.pem

Edit /service/lighttpd/root/lighttpd.conf and add:

$SERVER["socket"] == ":443" {
  ssl.engine = "enable"
  ssl.pemfile = "/root/.lighttpdssl/lighttpd.pem"
}

Redirect http to https
How to Redirect HTTP to HTTPS
Enable mod_redirect in your lighttpd.conf:

server.modules = (
"mod_redirect",
)
  • redirect everything

    $HTTP["scheme"] == "http" {
        # capture vhost name with regex conditiona -> %0 in redirect pattern
        # must be the most inner block to the redirect rule
        $HTTP["host"] =~ ".*" {
            url.redirect = (".*" => "https://%0$0")
        }
    }
  • specific url
    $HTTP["scheme"] == "http" {
      $HTTP["host"] =~ ".*" {
        url.redirect = ("^/phpmyadmin/.*" => "https://%0$0")
      }
    }
  • only for specific vhost and url
    $HTTP["scheme"] == "http" {
      $HTTP["host"] == "sth.example.com" {
        url.redirect = ("^/phpmyadmin/.*" => "https://sth.example.com$0" )
      }
    }

Recent Updates

  • PHP
    1 year 4 months ago
    PHP 7.4
  • 1 year 5 months ago
    MariaDB 10.4.12
  • 1 year 5 months ago
    Dovecot 2.3.10
  • 1 year 5 months ago
    CentOS 6 revisions
  • 1 year 5 months ago
    Copy of the revision from Wed, 08/22/2018 - 13:39.