lighttp 简易部署SSL

下载 apache 版的证书,执行下面命令,注意,域名改成自己的:

cat urdomain.xxx.key <(echo) urdomain.xxx.crt > urdomain.xxx.pem
sudo cp urdomain.xxx.pem root_bundle.crt /etc/lighttpd/ssl/

/etc/lighttd/lighttpd.conf 做如下更改:

`server.modules += ()段增加 mod_openssl

server.modules += (
        "mod_openssl",
        "mod_setenv",
        "mod_compress",
        "mod_dirlisting",
        "mod_staticfile",
        "mod_accesslog",
)

配置SSL文件,并将http80默认转到https443

$SERVER["socket"] == ":443" {
        ssl.engine = "enable"                      # 是否开启SSL
        ssl.pemfile = "/etc/lighttpd/ssl/urdomain.xxx.pem"   # 合并后的私钥和公钥
        ssl.ca-file = "/etc/lighttpd/ssl/root_bundle.crt"    # 证书信任链文件路径
        server.document-root = "/var/www/html/"         # 网站根目录
        ssl.cipher-list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE"        # 配置加密方式
}

$SERVER["socket"] == ":80" {
        $HTTP["host"] =~ ".*" {
                url.redirect = ( ".*" => "https://%0$0" )
        }
}

$HTTP["scheme"] == "https" {
        setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=31536000; includeSubdomains; preload" )
}

搞掂,装载SSL:

sudo /etc/init.d/lighttpd reload

涉及软件版本:lighttpd/1.4.55 (ssl) 、Ubuntu 20.04.5 LTS

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值