2017-10-04 54 views
0

我有以下方式簡單泊塢窗容器運行在Nginx的:letsencrypt根目錄提供了404位於泊塢窗

docker service create --name nginx_proxy \ 
    --mount type=bind,source=/opt/nginx/conf.d,target=/etc/nginx/conf.d \ 
    --mount type=bind,source=/opt/nginx/webroot,target=/var/webroot \ 
    --constraint 'node.role==manager' \ 
    --publish 80:80 --publish 443:443 \ 
    --network nginx-net \ 
    nginx 

創建的服務沒有問題運行。我補充說,通過代理在同一網絡(example.com.conf)其他服務的示例配置:(WWW)

server { 
    listen 80; 
    server_name example.com www.example.com; 
    location /.well-known/acme-challenge { 
    alias /var/webroot; 
    } 

    location/{ 
    proxy_pass http://example_site:8080; 
    } 
} 

當我去example.com,我可以看到我的網站。由於我將host:/ opt/nginx/webroot裝載到容器:/ var/webroot,我在/ opt/nginx/webroot中創建了一個名爲「test.html」的文件(文件內容無關緊要)。

當我打開我的瀏覽器,鍵入:

http://example.com/.well-known/acme-challenge/test.html 

我可以查看我添加到/ opt/nginx的/ Webroot公司的文件。但是,當我運行以下命令時certbot會拋出404:

certbot certonly --dry-run --webroot -w /opt/nginx/webroot -d example.com -d www.example.com 

我在這裏丟失了什麼?據我瞭解,certbot在webroot目錄下創建一個文件並嘗試公開下載文件;但是,由於某種原因它沒有看到我的文件。

+0

您可以發佈certbot和Nginx的日誌? – Moema

回答

0

我相信你的問題可能是由於對certbot命令中-w的誤解。 -w或--webroot-path指定包含由Web服務器提供的文件的頂級目錄。

Certbot將爲此創建子文件夾以應對挑戰,在您的情況下,certbot將創建/opt/nginx/webroot/.well-known/acme-challenge/,但您的nginx配置指向webroot本身。

https://certbot.eff.org/docs/using.html#webroot

考慮更改

location /.well-known/acme-challenge { 
    alias /var/webroot; 
    } 

到這樣的事情

location /.well-known/acme-challenge { 
    alias /var/webroot/.well-known/acme-challenge; 
    }