运行docker-compose up时出现以下错误:
backend_1_a5b5a2caf6fc | 2019/04/28 21:40:49 [emerg] 1#1: no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/default.conf:4
backend_1_a5b5a2caf6fc | nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/default.conf:4
...
...
production_backend_1_a5b5a2caf6fc exited with code 1
这是我的Nginx Dockerfile:
FROM nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
default.conf:
fastcgi_cache_path /dev/shm levels=1:2 keys_zone=laravel:100m;
fastcgi_cache_key "$scheme$request_method$host$request_uri$query_string";
server {
listen 80 default_server;
root /var/www/public;
index index.php index.html;
client_max_body_size 5M;
...
...
docker-compose.yml:
version: '3'
services:
backend:
build: ./nginx
depends_on:
- db
- redis
working_dir: /var/www
volumes:
- ../../src:/var/www
ports:
- 80:80
...
...
答案 0 :(得分:1)
这意味着您没有正确设置ssl(缺少服务器证书)。由于您已在docker-compose中映射了端口80,而不是443,所以我假设您将不使用SSL。
只需在nginx.conf
中删除以下行即可禁用ssl:
listen 443 ssl http2;
确保重建并重新启动您的nginx容器。
答案 1 :(得分:0)
您是否还有其他服务器正在监听端口443。请尝试从/ etc / nginx / sites-enabled中删除所有符号链接,但要使这台服务器正常工作
答案 2 :(得分:0)
但是,如果有人需要使用SSL,则此错误意味着您的server
部分缺少ssl_certificate
和ssl_certificate_key
声明。您需要具有.crt
和.key
文件才能与ssl一起运行。
应该看起来像
server {
listen 80;
listen 443 default_server ssl;
ssl_certificate /etc/nginx/certs/default.crt;
ssl_certificate_key /etc/nginx/certs/default.key;
... other declarations
}