2016-05-31 79 views
0

我现在丢掉了所有的头发。Certbot:无法将nginx配置为webroot

我想安装Certbot(letsencrypt)到我的服务器。但我不能甚至使URL 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; 
    } 

} 

但是URL不可用:

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 

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

回答

1

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

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

我不完全确定它,但我见过其他人这样做,它似乎为我工作。

+0

感谢您的帮助。我的错误比这更笨拙,我会在下面报告。 –

0

我终于找到了解决办法:

nginx的配置部位是在/etc/nginx/sites-available但不是在/etc/nginx/sites-enabled

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

我仍然不明白的链接的用例不是象征性的,但在我的情况下,这是问题。