我按照指南创建了一个 nginx 和 letenscrypt 容器:使用 Docker 设置具有自动 SSL 生成的 Nginx 反向代理。我的docker-compose.yml看起来像:
version: "3.7"
services:
reverse-proxy:
image: "jwilder/nginx-proxy:latest"
container_name: "reverse-proxy"
volumes:
- "html:/usr/share/nginx/html"
- "dhparam:/etc/nginx/dhparam"
- "vhost:/etc/nginx/vhost.d"
- "certs:/etc/nginx/certs"
- "/run/docker.sock:/tmp/docker.sock:ro"
restart: "always"
networks:
- "net"
ports:
- "83:83"
- "444:444"
letsencrypt:
image: "jrcs/letsencrypt-nginx-proxy-companion:latest"
container_name: "letsencrypt-helper"
volumes:
- "html:/usr/share/nginx/html"
- "dhparam:/etc/nginx/dhparam"
- "vhost:/etc/nginx/vhost.d"
- "certs:/etc/nginx/certs"
- "/run/docker.sock:/var/run/docker.sock:ro"
environment:
NGINX_PROXY_CONTAINER: "reverse-proxy"
DEFAULT_EMAIL: "[email protected]"
restart: "always"
depends_on:
- "reverse-proxy"
networks:
- "net"
volumes:
certs:
html:
vhost:
dhparam:
networks:
net:
external: true
代替[电子邮件保护]我写了我的 Gmail 邮件。当我在终端中编写它时:
docker run --rm --name nginx-dummy -e VIRTUAL_HOST=my-domain.duckdns.org -e LETSENCRYPT_HOST=my-domain.duckdns.org -e VIRTUAL_PORT=83 --network net -d nginx:latest
我得到了 nginx-dummy 日志:
nginx.1 | 2023/01/06 16:29:27 [notice] 19#19: signal 17 (SIGCHLD) received from 33
dockergen.1 | 2023/01/06 16:29:36 Received event start for container 68ca2a394500
dockergen.1 | 2023/01/06 16:29:36 Generated '/etc/nginx/conf.d/default.conf' from 11 containers
dockergen.1 | 2023/01/06 16:29:36 Running 'nginx -s reload'
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: signal 1 (SIGHUP) received from 57, reconfiguring
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: reconfiguring
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: using the "epoll" event method
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: start worker processes
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: start worker process 58
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: start worker process 59
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: start worker process 60
nginx.1 | 2023/01/06 16:29:36 [notice] 19#19: start worker process 61
nginx.1 | 2023/01/06 16:29:37 [notice] 52#52: gracefully shutting down
nginx.1 | 2023/01/06 16:29:37 [notice] 53#53: gracefully shutting down
nginx.1 | 2023/01/06 16:29:37 [notice] 55#55: gracefully shutting down
nginx.1 | 2023/01/06 16:29:37 [notice] 54#54: gracefully shutting down
nginx.1 | 2023/01/06 16:29:37 [notice] 55#55: exiting
nginx.1 | 2023/01/06 16:29:37 [notice] 52#52: exiting
nginx.1 | 2023/01/06 16:29:37 [notice] 53#53: exiting
nginx.1 | 2023/01/06 16:29:37 [notice] 54#54: exiting
nginx.1 | 2023/01/06 16:29:37 [notice] 52#52: exit
nginx.1 | 2023/01/06 16:29:37 [notice] 55#55: exit
nginx.1 | 2023/01/06 16:29:37 [notice] 53#53: exit
nginx.1 | 2023/01/06 16:29:37 [notice] 54#54: exit
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: signal 17 (SIGCHLD) received from 54
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: worker process 53 exited with code 0
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: worker process 54 exited with code 0
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: signal 29 (SIGIO) received
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: signal 17 (SIGCHLD) received from 52
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: worker process 52 exited with code 0
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: signal 29 (SIGIO) received
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: signal 17 (SIGCHLD) received from 55
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: worker process 55 exited with code 0
nginx.1 | 2023/01/06 16:29:37 [notice] 19#19: signal 29 (SIGIO) received
dockergen.1 | 2023/01/06 16:31:17 Received event die for container 68ca2a394500
dockergen.1 | 2023/01/06 16:31:18 Received event stop for container 68ca2a394500
dockergen.1 | 2023/01/06 16:31:18 Generated '/etc/nginx/conf.d/default.conf' from 10 containers
dockergen.1 | 2023/01/06 16:31:18 Running 'nginx -s reload'
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: signal 1 (SIGHUP) received from 63, reconfiguring
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: reconfiguring
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: using the "epoll" event method
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: start worker processes
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: start worker process 64
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: start worker process 65
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: start worker process 66
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: start worker process 67
dockergen.1 | 2023/01/06 16:31:18 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx.1 | 2023/01/06 16:31:18 [notice] 58#58: gracefully shutting down
nginx.1 | 2023/01/06 16:31:18 [notice] 59#59: gracefully shutting down
nginx.1 | 2023/01/06 16:31:18 [notice] 61#61: gracefully shutting down
nginx.1 | 2023/01/06 16:31:18 [notice] 60#60: gracefully shutting down
nginx.1 | 2023/01/06 16:31:18 [notice] 59#59: exiting
nginx.1 | 2023/01/06 16:31:18 [notice] 61#61: exiting
nginx.1 | 2023/01/06 16:31:18 [notice] 60#60: exiting
nginx.1 | 2023/01/06 16:31:18 [notice] 58#58: exiting
nginx.1 | 2023/01/06 16:31:18 [notice] 61#61: exit
nginx.1 | 2023/01/06 16:31:18 [notice] 58#58: exit
nginx.1 | 2023/01/06 16:31:18 [notice] 59#59: exit
nginx.1 | 2023/01/06 16:31:18 [notice] 60#60: exit
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: signal 17 (SIGCHLD) received from 61
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: worker process 58 exited with code 0
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: worker process 61 exited with code 0
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: signal 29 (SIGIO) received
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: signal 17 (SIGCHLD) received from 59
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: worker process 59 exited with code 0
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: worker process 60 exited with code 0
nginx.1 | 2023/01/06 16:31:18 [notice] 19#19: signal 29 (SIGIO) received
dockergen.1 | 2023/01/06 16:31:30 Received event start for container 2a93290cd6ea
dockergen.1 | 2023/01/06 16:31:30 Generated '/etc/nginx/conf.d/default.conf' from 11 containers
dockergen.1 | 2023/01/06 16:31:30 Running 'nginx -s reload'
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 1 (SIGHUP) received from 70, reconfiguring
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: reconfiguring
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: using the "epoll" event method
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: start worker processes
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: start worker process 71
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: start worker process 72
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: start worker process 73
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: start worker process 74
nginx.1 | 2023/01/06 16:31:30 [notice] 64#64: gracefully shutting down
nginx.1 | 2023/01/06 16:31:30 [notice] 65#65: gracefully shutting down
nginx.1 | 2023/01/06 16:31:30 [notice] 67#67: gracefully shutting down
nginx.1 | 2023/01/06 16:31:30 [notice] 66#66: gracefully shutting down
nginx.1 | 2023/01/06 16:31:30 [notice] 67#67: exiting
nginx.1 | 2023/01/06 16:31:30 [notice] 65#65: exiting
nginx.1 | 2023/01/06 16:31:30 [notice] 64#64: exiting
nginx.1 | 2023/01/06 16:31:30 [notice] 66#66: exiting
nginx.1 | 2023/01/06 16:31:30 [notice] 66#66: exit
nginx.1 | 2023/01/06 16:31:30 [notice] 64#64: exit
nginx.1 | 2023/01/06 16:31:30 [notice] 65#65: exit
nginx.1 | 2023/01/06 16:31:30 [notice] 67#67: exit
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 17 (SIGCHLD) received from 65
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: worker process 65 exited with code 0
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: worker process 67 exited with code 0
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 29 (SIGIO) received
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 17 (SIGCHLD) received from 67
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: worker process 64 exited with code 0
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 29 (SIGIO) received
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 17 (SIGCHLD) received from 66
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: worker process 66 exited with code 0
nginx.1 | 2023/01/06 16:31:30 [notice] 19#19: signal 29 (SIGIO) received
我在路由器上打开了端口 83,但没有看到欢迎 nginx 网页。我哪里做错了?谢谢帮助。
我使用 OMV 系统在计算机上完成了这项工作。
我关闭了所有其他容器,更改了子域名和端口,但什么都不起作用。