docker-compose 无法打开 letsencrypt/options-ssl-nginx.conf 文件 nginx.conf
docker-compose failed to open letsencrypt/options-ssl-nginx.conf file in nginx.conf
我在使用 Docker Compose 时遇到问题。
我有以下 Dockerfile
:
version: "3.7"
services:
backend:
...
frontend:
...
nginx:
container_name: nginx
image: nginx:latest
volumes:
- ./nginx:/etc/nginx/nginx.conf
depends_on:
- backend
- frontend
ports:
- 80:80
- 443:443
restart: on-failure
volumes:
db:
我的 nginx.conf
文件如下所示:
events {
}
http {
client_max_body_size 20m;
server {
server_name barrymichaeldoyle.com;
location / {
proxy_pass http://frontend:8080;
}
location /api/ {
proxy_pass http://backend:17001;
}
listen 80;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/barrymichaeldoyle.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/barrymichaeldoyle.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
}
我只是希望它能工作(在我尝试启用 SSL 之前它就在工作)。
相反,我收到以下错误:
知道发生了什么事吗?我认为这与我的 volumes
有关,其中 /etc/letsencrypt/options-ssl-nginx.conf
无法访问,但我不知道如何将其包含在容器中。
我在 docker-compose
文件中围绕 volumes
尝试了一系列变体,但似乎没有任何效果。
这很简单,您需要将容器(您的主机)外部的文件挂载到您的容器中,这就是 volumes
所做的(过于简单化)。
有些像这样,前提是这些文件在您主机上的那个位置,否则您的路径可能不同。
volumes:
- ./nginx:/etc/nginx/nginx.conf # you already linked your config
- /etc/letsencrypt/options-ssl-nginx.conf:/etc/letsencrypt/options-ssl-nginx.conf # link tls config
- /etc/letsencrypt/ssl-dhparams.pem:/etc/letsencrypt/ssl-dhparams.pem # link params
- /etc/letsencrypt/live/certname:/etc/letsencrypt/live/certname # link the cert folder
您需要不经意地更改 certname
。
我在使用 Docker Compose 时遇到问题。
我有以下 Dockerfile
:
version: "3.7"
services:
backend:
...
frontend:
...
nginx:
container_name: nginx
image: nginx:latest
volumes:
- ./nginx:/etc/nginx/nginx.conf
depends_on:
- backend
- frontend
ports:
- 80:80
- 443:443
restart: on-failure
volumes:
db:
我的 nginx.conf
文件如下所示:
events {
}
http {
client_max_body_size 20m;
server {
server_name barrymichaeldoyle.com;
location / {
proxy_pass http://frontend:8080;
}
location /api/ {
proxy_pass http://backend:17001;
}
listen 80;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/barrymichaeldoyle.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/barrymichaeldoyle.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
}
我只是希望它能工作(在我尝试启用 SSL 之前它就在工作)。
相反,我收到以下错误:
知道发生了什么事吗?我认为这与我的 volumes
有关,其中 /etc/letsencrypt/options-ssl-nginx.conf
无法访问,但我不知道如何将其包含在容器中。
我在 docker-compose
文件中围绕 volumes
尝试了一系列变体,但似乎没有任何效果。
这很简单,您需要将容器(您的主机)外部的文件挂载到您的容器中,这就是 volumes
所做的(过于简单化)。
有些像这样,前提是这些文件在您主机上的那个位置,否则您的路径可能不同。
volumes:
- ./nginx:/etc/nginx/nginx.conf # you already linked your config
- /etc/letsencrypt/options-ssl-nginx.conf:/etc/letsencrypt/options-ssl-nginx.conf # link tls config
- /etc/letsencrypt/ssl-dhparams.pem:/etc/letsencrypt/ssl-dhparams.pem # link params
- /etc/letsencrypt/live/certname:/etc/letsencrypt/live/certname # link the cert folder
您需要不经意地更改 certname
。