我真的对此束手无策!首先,似乎没有办法LetsEncrypt无需激活域名即可进行验证过程!(当您尝试从一台服务器移动至另一台服务器时,这很糟糕)

然后,我似乎无法得到acme 挑战可以正常工作。这是我的域主机配置nginx

server {
    listen      xxx.xxx.xxx.xxx:80;
    server_name test.co.uk www.test.co.uk;
    root        /home/rachel/web/test.co.uk/public_html;

      # Necessary for Let's Encrypt Domain Name ownership validation
      location /.well-known/acme-challenge/ {
        try_files $uri /dev/null =404;
      }
      location / {
        return 301 https://$host$request_uri;
      }
}
server {
    listen      xxx.xxx.xxx.xxx;
    server_name cdn.test.co.uk ;
    root        /home/rachel/web/cdn.test.co.uk/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/cdn.test.co.uk.log combined;
    access_log  /var/log/nginx/domains/cdn.test.co.uk.bytes bytes;
    error_log   /var/log/nginx/domains/cdn.test.co.uk.error.log error;

      # Necessary for Let's Encrypt Domain Name ownership validation
      location /.well-known/acme-challenge/ {
        try_files $uri /dev/null =404;
      }
      location / {
        return 301 https://$host$request_uri;
      }
}

我创建了一个测试文件 foo.html,并将其放在 /.well-known/foo.html 文件夹中。然后进入浏览器:

http://test.co.uk/.well-known/foo.html

我收到 403 错误。我做错了什么?我不明白为什么这样做这么复杂!

谢谢(希望你能挽救我剩下的一点头发;))

答案1

唉,我真的应该先在这里发布我的问题!几乎每次我发布后都能找到正确的解决方案!

Necessary for Let's Encrypt Domain Name ownership validation
location '/.well-known/acme-challenge' {
    root /home/rachel/web/cdn.test.co.uk/public_html;
}

location / {
      if ($scheme = http) {
        return 301 https://cdn.test.co.uk$request_uri;
      }
}

希望这可以帮助别人!

相关内容