我在 DigitalOcean Droplet 中的 Ubuntu 18.04 LTS Bionic 上运行 Nginx
我按照指示从https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx运行命令。
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx
然后是“1 step setup”命令
sudo certbot --nginx
一切正常,直到我去跑步
docker-compose up --build
它返回
Creating nginx ... error
ERROR: for nginx Cannot start service nginx: b'driver failed programming external connectivity on endpoint nginx (69110ad70db81c0b563eac20f90a94358702588dcbd604d7672292d8f082d3862607):
Error starting userland proxy: listen tcp 0.0.0.0:443: bind: address already in use'
ERROR: for nginx Cannot start service nginx: b'driver failed programming external connectivity on endpoint nginx (69011ad70db81c0b563eac20f90a94358702588dcbd604d7672292d8f082d3862607):
Error starting userland proxy: listen tcp 0.0.0.0:443: bind: address already in use'
ERROR: Encountered errors while bringing up the project.
我的 .conf 文件看起来像这样(显然使用“sudo certbot --nginx”命令进行了更新)
server {
listen 80;
listen [::]:80 default_server;
server_name www.domain.com domain.com;
location / {
proxy_pass http://website:8000;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
} }
docker-compose nginx 服务
nginx:
restart: always
build: ./nginx
image: 'nginx:1.13'
container_name: nginx
volumes:
- .:/domain
ports:
- 80:80
- 443:443
networks:
- web_nw
links:
- domain
depends_on:
- domain
我错过了什么?它必须如此简单,但我无法弄清楚如何让我的 Nginx 容器启动并使用新分配的 Https/SSL 运行。
有没有人遇到过这个?