lighttpd支持HTTPS

隨著Apple、Google大力推廣HTTPS,HTTPS將成為今后網(wǎng)站的主流,而前段時(shí)間正好看到Let’s Encrypt可以生成免費(fèi)的SSL證書。因此嘗試配置了下lighttpd,發(fā)現(xiàn)非常容易,大體步驟如下:

申請證書

1. 獲取Certbot

git clone https://github.com/certbot/certbot

2. 申請證書

cd certbot
./letsencrypt-auto certonly -d smallmuou.xyz

PS: 選擇Automatically use a temporary webserver(stadalone)

3. 配置證書

成功后,會(huì)生成如下幾個(gè)文件

smallmuou:~ $ tree /etc/letsencrypt/live/smallmuou.xyz/
/etc/letsencrypt/live/smallmuou.xyz/
|-- cert.pem -> ../../archive/smallmuou.xyz/cert1.pem
|-- chain.pem -> ../../archive/smallmuou.xyz/chain1.pem
|-- fullchain.pem -> ../../archive/smallmuou.xyz/fullchain1.pem
|-- privkey.pem -> ../../archive/smallmuou.xyz/privkey1.pem
|-- README

PS: 各個(gè)文件的含義可以查看README的說明,我也給出我的理解

  • cert.pem 公鑰
  • prikey.pem 私鑰
  • fullchain.pem CA證書信任鏈 (包含Root Certificate)
  • chain.pem 上一級CA證書(這里指Let's Encrypt)

PS: 可以通過cat cert.pem prikey.pem > server.pem將私有和公用打包在一起,以供后續(xù)lighttpd配置使用.

信任鏈(chain)即證書的信任關(guān)系,如A信任A1,A1信任A2,其中最頂級的節(jié)點(diǎn)就是根證書(root certificate),Let’s Encrypt就是直接隸屬于root certificate.

└── DST Root CA X3
    └── Let's Encrypt Authority X3
        └── smallmuou.xyz

安裝及配置lighttpd

1. 安裝SSL

yum install openssl*

2. 下載

進(jìn)入lighttpd官網(wǎng),下載lighttpd源碼包

wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.45.tar.gz

3. 解壓并編譯

tar xzvf lighttpd-1.4.45.tar.gz
cd lighttpd-1.4.45
./autogen.sh
./configure --with-openssl --with-openssl-libs=/usr/lib
make 
make install

PS: 安裝完后,執(zhí)行lighttpd -v,當(dāng)有出現(xiàn)(ssl)字樣,則表示lighttpd已支持SSL

4. 配置

進(jìn)入doc/config編輯lighttpd.conf文件,添加如下內(nèi)容

$SERVER["socket"] == "0.0.0.0:443" {
  ssl.engine                  = "enable"
  ssl.pemfile                 = "/etc/letsencrypt/live/smallmuou.xyz/server.pem"
  ssl.ca-file                 = "/etc/letsencrypt/live/smallmuou.xyz/fullchain.pem"
  server.document-root        = "/srv/www/htdocs"
}

  • ssl.engine 是否開啟SSL
  • ssl.pemfile pem文件位置(包含私有和公用)
  • ssl.ca-file CA證書
  • server.document-root 根路徑
    點(diǎn)擊此處查看更多選項(xiàng)內(nèi)容

5. 完成

經(jīng)過以上步驟,重新啟動(dòng)lighttpd -f lighttpd.conf,就可以使用https訪問,而且是受信任的. 親測有效.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容