我如何设置letsencrypt与多个域在Ubuntu的16.04 lighttpd服务器?

我试图从lighttpd从头开始设置letsencrypt。 我目前在16.10 xenial上运行lighttpd,并希望将现有网站移到https的http。 我知道有一个Apache和ngnix的自动设置过程,但我不想移动的东西。 我有六个主机名,通过使用虚拟主机托pipe的一对域以及每个主机的单个块。

我将如何做到这一点?

它花了一些尝试和错误,并把多个来源的位放在一起。

根据您的需要,您可能希望做一些不同的事情。 在这种情况下,我还没有做过几件事情,有些事情是可选的。

我以这个向导开始,并且分歧很大

如果你想生成自己的ssl.dh文件现在就做 。 它的可选,需要一段时间

cd /etc/ssl/certs

然后

openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096很慢, 有点多余 openssl dhparam -dsaparam -out etc/ssl/certs/dhparam.pem要快得多

接下来,按照说明安装letsencrypt的certbot

 $ sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-get install certbot 

生成你的证书。 我select在一个证书的“example.com”域中为我的所有主机颁发一个证书,并在自己的证书上拥有“example.org”。

certbot使用你的Web服务器端口,所以先closures你的lighttpd实例

生成一个证书只是一个运行的问题

certbot certonly --standalone -d example.org一个域和certbot certonly --standalone -d example.com -d chat.example.com多个域(最多20个)证书。

lighttpd需要一个单独的文件,letsencrypt做一对(最初!),所以你需要合并它们。 转到cd /etc/letsencrypt/live/进入每个文件夹并运行cat privkey.pem cert.pem > ssl.pem

出于我们的目的,假设您在“/etc/letsencrypt/live/chat.example.com/”和“/etc/letsencrypt/live/example.org/”中有文件

出于testing目的,假设您希望将其中一个证书作为默authentication书,并且希望保留端口80以进行testing,以查看服务器是否以您的更改开始。

添加一个块阅读

 $SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "/etc/letsencrypt/live/chat.example.com/ssl.pem" ssl.ca-file = "/etc/letsencrypt/live/chat.example.com/fullchain.pem" } 

您可以稍后replace它,并且是最低限度的,可以让您在http旁边运行https。

任何没有连接到https的明确设置的主机都将使用这些证书。 它是一个最小的可行的设置来testing。

启动lighttpd并testing。

现在,如果你是认真的,你可能需要更多的设置,比如使用我们提到的ssl.dh设置,并且你在开始时花了两个小时生成一个dhparam.pem文件。你可以replace刚添加的块像这样 – 这是整个服务器的默认设置。

 $SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "/etc/letsencrypt/live/chat.example.com/ssl.pem" ssl.ca-file = "/etc/letsencrypt/live/chat.example.com/fullchain.pem" ssl.dh-file = "/etc/ssl/certs/jmg2dhparam.pem" ssl.ec-curve = "secp384r1" ssl.honor-cipher-order = "enable" ssl.cipher-list = "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH" ssl.use-compression = "disable" } $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") } } 

它使用更完整的设置(适应味道)进行HTTPS,并将任何HTTP连接redirect到HTTPS。

如果你想要一个不同的密钥组的域,你可以覆盖主机块中的这些设置。

 $HTTP["host"] =~ "(^|\.)example\.org$" { server.document-root = "/var/www/example" server.errorlog = "/var/log/lighttpd/example/error.log" accesslog.filename = "/var/log/lighttpd/example/access.log" server.error-handler-404 = "/e404.php" ssl.pemfile = "/etc/letsencrypt/live/example.org/ssl.pem" ssl.ca-file = "/etc/letsencrypt/live/example.org/fullchain.pem" } 

重新启动服务器,testing以确保端口80不可连接,并且https是,你应该是好的。

大多数工具都支持“愚蠢的networking服务器”模式,在这种模式下,他们提供的文件需要由您的networking服务器在/.well-known/acme-challenge/目录中提供。

也可以使用一些dynamic语言(lua,php,…:concat请求文件名, '.'和公共密钥哈希)来生成内容'.'