【问题标题】:Certbot: cannot config nginx to webrootCertbot:无法将 nginx 配置为 webroot
【发布时间】:2016-09-29 20:45:13
【问题描述】:

我现在头发都掉光了。

我正在尝试将 Certbot (letsencrypt) 设置到我的服务器。但我什至无法使用以下网址提供http://myapp.com/.well-known/acme-challenge/myfile 网址:

namei -om /var/www/certbot/.well-known/acme-challenge/myfile 
f: /var/www/certbot/.well-known/acme-challenge/myfile
 drwxr-xr-x 1000 1000 /
 drwxr-xr-x root root var
 drwxr-xr-x root root www
 drwxr-xr-x root root certbot
 drwxr-xr-x root root .well-known
 drwxr-xr-x root root acme-challenge
 -rw-r--r-- root root myfile

以及以下 nginx 配置:

upstream myapp {
  server                localhost:3000;
}

server {
  listen                80;
  server_name           myapp.com;

  location /.well-known/acme-challenge {
    default_type "text/plain";
    root /var/www/certbot;
  }

  location / {
    proxy_pass          http://myapp;
    proxy_read_timeout  90;
  }

}

但网址不可用:

curl -I http://myapp.com/.well-known/acme-challenge/myfile
HTTP/1.1 404 Not Found
Server: nginx/1.6.2
Date: Tue, 31 May 2016 17:40:23 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 47
Connection: keep-alive
X-Powered-By: Express
X-Content-Type-Options: nosniff

我做错了什么???请帮帮我!

【问题讨论】:

    标签: nginx lets-encrypt certbot


    【解决方案1】:

    我认为您应该引用该位置,因为它包含一个点。像这样:

    location '/.well-known/acme-challenge/' {
       # ...
    }
    

    我对此并不完全确定,但我见过其他人这样做,它似乎对我有用。

    【讨论】:

    • 感谢您的帮助。我的错误比这更愚蠢,我将在下面报告。
    【解决方案2】:

    我终于找到了解决办法:

    nginx 配置站点在/etc/nginx/sites-available,但不在/etc/nginx/sites-enabled

    我确实创建了从前者到后者的链接,但它不是符号链接(缺少ln /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled 中的-s 选项)。

    我仍然不明白不是符号链接的用例,但在我的情况下,这就是问题所在。

    【讨论】:

      猜你喜欢
      • 2017-06-29
      • 2019-07-28
      • 2019-09-04
      • 1970-01-01
      • 2012-10-14
      • 2017-03-02
      • 1970-01-01
      • 2020-08-24
      • 2021-05-16
      相关资源
      最近更新 更多