我想通过以下方式启用 ssldocker-letsencrypt-nginx-proxy-companion
。
这是 docker-compose.yml
version: "3.3"
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- certs:/etc/nginx/certs:ro
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/tmp/docker.sock:ro
restart: always
db:
# ---
wordpress:
# ---
environment:
# ---
VIRTUAL_HOST: blog.ironsand.net
LETSENCRYPT_HOST: blog.ironsand.net
LETSENCRYPT_EMAIL: [email protected] /cdn-cgi/l/email-protection
restart: always
letsencrypt-nginx-proxy-companion:
container_name: letsencrypt
image: jrcs/letsencrypt-nginx-proxy-companion
volumes:
- certs:/etc/nginx/certs
- vhostd:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
NGINX_PROXY_CONTAINER: nginx-proxy
restart: always
networks:
default:
external:
name: nginx-proxy
volumes:
certs:
vhostd:
html:
docker logs letsencrypt
显示证书已经存在。
/etc/nginx/certs/blog.ironsand.net /app
Creating/renewal blog.ironsand.net certificates... (blog.ironsand.net)
2020-04-09 00:03:23,711:INFO:simp_le:1581: Certificates already exist and renewal is not necessary, exiting with status code 1.
/app
但 ACME 挑战没有返回任何结果。 (失败?)
$ docker exec letsencrypt bash -c 'echo "Hello world!" > /usr/share/nginx/html/.well-known/acme-challenge/hello-world'
$
端口 443 正在侦听,但该端口从外部关闭。
// in remote server
$ sudo lsof -i:443
[sudo] password for ubuntu:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 10910 root 4u IPv6 633694 0t0 TCP *:https (LISTEN)
// from local pc
❯ nmap -p 443 blog.ironsand.net
Starting Nmap 7.80 ( https://nmap.org ) at 2020-04-09 09:44 JST
Nmap scan report for blog.ironsand.net (153.127.40.107)
Host is up (0.035s latency).
rDNS record for 153.127.40.107: ik1-418-41103.vs.sakura.ne.jp
PORT STATE SERVICE
443/tcp closed https
Nmap done: 1 IP address (1 host up) scanned in 0.21 seconds
我正在使用数据包过滤,但它对 80 和 443 开放,而且我没有使用防火墙。
我怎样才能进一步调查问题所在?
我无法直接解决你的问题,但我可以写一些提示,这样可以解决你的问题。
你的命令什么也不返回。
bash -c 'echo "Hello world!" > /usr/share/nginx/html/.well-known/acme-challenge/hello-world'
该命令仅写入“Hello world!”到该位置,通常不会返回任何内容。看https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Redirections https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Redirections
查看 certs 文件夹内部。
查看 certs 文件夹并清理它们。检查该文件夹是否已正确安装在您的 nginx 容器中。对容器执行 bash 操作并检查 ssl 文件夹。
检查防火墙是否没有中断
从外部可能没有连接吗?什么是从里面来的?登录您的 docker 主机并检查那里的连接(也许openssl https://www.feistyduck.com/library/openssl-cookbook/online/ch-testing-with-openssl.html and curl https://curl.haxx.se/是你的朋友),
不要在容器内使用 SSL。
当有人尝试将 ssl 与 ACME 映像和“狂野安装和共享卷”一起使用时,我经常会遇到问题。但当同一个人使用普通的反向代理时,我从未听说过任何问题。我在下面解释了一个好的设置。
因此,只需从容器中删除整个 Letscrypt-code 并关闭容器的 443 端口即可。
(此外,您可以切换到非 root 映像并仅公开不需要 root 权限的端口。)
然后在你的主机上安装 nginx 并设置反向代理(类似于proxy_pass 127.0.0.1:8080
)。现在安装certbot
并启动它。它可以帮助您并且简单明了。
The certbot
还可以维护您的证书。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)