• 学派吧-由新云网络独家赞助-https://www.sq9.cn。

如何在Lighttpd Server中配置SSL的教程分享

unix admin 5年前 (2019-05-07) 2629次浏览 已收录 0个评论 扫描二维码

所有使用SSL运行的站点都在默认端口443上使用了https协议。SSL通过加密服务器和客户端之间的数据来提供安全的数据通信。

在我们之前的文章中,我们已经介绍了如何在CentOS/RHEL系统中安装LightTPD和创建虚拟主机。本文将继续介绍在LightTPD服务器中配置SSL。对于本篇文章中的示例,我们使用的是自签名证书。

如果要在apache/httpd中查找configure ssl,那么可能需要阅读本篇文章。

步骤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

 


学派吧 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:如何在Lighttpd Server中配置SSL的教程分享
喜欢 (0)
[pay@sq9.cn]
分享 (0)
关于作者:
腾讯云-运维运维 QQ 690624
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址