所有使用ssl運行的站點都在默認端口443上使用了https協議。ssl通過加密服務器和客戶端之間的數據來提供安全的數據通信。
在我們之前的文章中,我們已經介紹了如何在CentOS/RHEL系統中安裝LightTPD和安裝LightTPD。本文將繼續介紹在LightTPD服務器中配置SSL。對于本篇文章中的示例,我們使用的是自簽名證書。
如果要在apache/httpd中查找configure ssl,那么可能需要閱讀安裝LightTPD。
步驟1:創建證書簽名請求(CSR)
對于創建SSL證書,第一個要求是創建私鑰和CSR。CSR是一個文件,其中包含有關域的所有詳細信息,包括公鑰。首先創建一個目錄,在其中創建CSR和密鑰。
#?mkdir?/etc/lighttpd/ssl/ #?cd?/etc/lighttpd/ssl/
現在使用以下命令創建CSR和密鑰文件。根據域更改文件名example.com.key和example.com.csr。此命令將要求輸入有關您的域的信息。了解有關創建CSR的更多信息。
#?openssl?req?-new?-newkey?rsa:2048?-nodes?-keyout?example.com.key?-out?example.com.csr
Generating?a?2048?bit?RSA?private?key ....+++ ...............+++ writing?new?private?key?to?'example.com.key' ----- 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]:TecAdmin?Inc. Organizational?Unit?Name?(eg,?section)?[]:web Common?Name?(eg,?your?name?or?your?server's?hostname)?[]:example.com Email?Address?[]:user@example.com Please?enter?the?following?'extra'?attributes to?be?sent?with?your?certificate?request A?challenge?password?[]:?[Leave?Blank] An?optional?company?name?[]:?[Leave?Blank]
步驟2:從CA請求證書
創建CSR后,從任意證書提供商(如geotrust、comodo、digicert或godaddy等)請求一個SSL證書。
或創建供內部使用的自簽名證書
#?openssl?x509?-req?-days?365?-inexample.com.csr-signkeyexample.com.key-outexample.com.crt
將在名為example.com.crt的當前目錄中獲取創建的證書文件。現在通過將密鑰文件和證書組合在一個文件中來創建pem文件
#?cat?example.com.key??example.com.crt?>?example.com.pem
步驟3:使用SSL設置虛擬主機
編輯lighttpd配置文件/etc/lighttpd/lighttpd.conf并添加以下值。
$SERVER["socket"]?==?":443"?{ ????????ssl.engine?=?"enable" ????????ssl.pemfile?=?"/etc/lighttpd/ssl/tecadmin.net.pem" ??????#?ssl.ca-file?=?"/etc/lighttpd/ssl/CA_issuing.crt" ????????server.name?=?"site1.tecadmin.net" ????????server.document-root?=?"/sites/vhosts/site1.tecadmin.net/public" ????????server.errorlog?=?"/var/log/lighttpd/site1.tecadmin.net.error.log" ????????accesslog.filename?=?"/var/log/lighttpd/site1.tecadmin.net.access.log" }
步驟4:驗證配置并重新啟動lighttpd
啟動lighttpd服務之前,請驗證配置文件的語法。
#?lighttpd?-t?-f?/etc/lighttpd/lighttpd.conf Syntax?OK
如果發現所有語法都正常,讓我們重新啟動服務。
#?service?lighttpd?restart
【相關推薦:安裝LightTPD】