标签 acme 下的文章

在 apche 里设置 acme 验证证书的目录

如这里提到的:https://doc.owncloud.com/server/next/admin_manual/installation/letsencrypt/apache.html

我拿来套用的例子:

<VirtualHost *:443>
    ServerName demo.anqun.org

  Alias /.well-known/acme-challenge/ /var/www/acme/.well-known/acme-challenge/
  <Directory "/var/www/acme/.well-known/acme-challenge/">
      Options None
      AllowOverride None
      ForceType text/plain
      RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)"
  </Directory>

 SSLEngine on
 SSLCertificateFile  /root/.acme.sh/demo.anqun.org_ecc/demo.anqun.org.cer
 SSLCertificateKeyFile /root/.acme.sh/demo.anqun.org_ecc/demo.anqun.org.key
 SSLCertificateChainFile  /root/.acme.sh/demo.anqun.org_ecc/ca.cer

</VirtualHost>

<VirtualHost *:80>
  ServerName demo.anqun.org
  Redirect permanent / https://demo.anqun.org/
  Alias /.well-known/acme-challenge/ /var/www/acme/.well-known/acme-challenge/
  <Directory "/var/www/acme/.well-known/acme-challenge/">
      Options None
      AllowOverride None
      ForceType text/plain
      RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)"
  </Directory>
</VirtualHost>

在 nginx 里设置 acme 验证证书的目录

需求:acme.sh 建议用非root的用户运行,如果nginx里有多个站点需要验证证书,怎么做较方便呢?

尝试:如 创建一个 acme.conf 的配置文件,内容如下:

#############################################################################
# Configuration file for Let's Encrypt ACME Challenge location
# This file is already included in listen_xxx.conf files.
# Do NOT include it separately!
#############################################################################
#
# This config enables to access /.well-known/acme-challenge/xxxxxxxxxxx
# on all our sites (HTTP), including all subdomains.
# This is required by ACME Challenge (webroot authentication).
# You can check that this location is working by placing ping.txt here:
# /var/www/letsencrypt/.well-known/acme-challenge/ping.txt
# And pointing your browser to:
# http://xxx.domain.tld/.well-known/acme-challenge/ping.txt
#
# Sources:
# https://community.letsencrypt.org/t/howto-easy-cert-generation-and-renewal-with-nginx/3491
#
#############################################################################

# Rule for legitimate ACME Challenge requests (like /.well-known/acme-challenge/xxxxxxxxx)
# We use ^~ here, so that we don't check other regexes (for speed-up). We actually MUST cancel
# other regex checks, because in our other config files have regex rule that denies access to files with dotted names.
location ^~ /.well-known/acme-challenge/ {

    # Set correct content type. According to this:
    # https://community.letsencrypt.org/t/using-the-webroot-domain-verification-method/1445/29
    # Current specification requires "text/plain" or no content header at all.
    # It seems that "text/plain" is a safe option.
    default_type "text/plain";

    # This directory must be the same as in /etc/letsencrypt/cli.ini
    # as "webroot-path" parameter. Also don't forget to set "authenticator" parameter
    # there to "webroot".
    # Do NOT use alias, use root! Target directory is located here:
    # /var/www/common/letsencrypt/.well-known/acme-challenge/
    root         /var/www/acme;
}

# Hide /acme-challenge subdirectory and return 404 on all requests.
# Ending slash is important!
location = /.well-known/acme-challenge/ {
    return 404;
}

然后让web用户在/var/www/acme有写入权限,再在所需站点的配置文件里引用这个acme.conf文件就可以啦。

参考:https://community.letsencrypt.org/t/how-to-nginx-configuration-to-enable-acme-challenge-support-on-all-http-virtual-hosts/5622/3

手工设置dns记录,申请Let's Encrypt泛域名证书

系统:debian9。

过程:

1.curl https://get.acme.sh | sh # 先安装acme申请证书脚本

2.source ~/.bashrc # 重载配置文件,可直接使用acme.sh命令

3.acme.sh --issue -d liujing.ltd -d *.liujing.ltd --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please # 手工添加dns记录来申请泛域名证书
acme-dns-domain-1.png

4.在域名解析面板里添加好相应的TXT记录
acme-dns-domain-2.png

5.需添加两条TXT记录
acme-dns-domain-3.png

6.acme.sh --renew -d liujing.ltd -d *.liujing.ltd --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please # 申请证书
acme-dns-domain-4.png

7.将申请到证书文件fullchain.cer和liujing.ltd.key配置到web站点后,在火狐浏览器查看站点证书信息,正常
acme-dns-domain-5.png

参考:https://github.com/Neilpang/acme.sh/wiki/dns-manual-mode