对于nginx容器,docker-compose up失败

问题描述 投票:1回答:2

当我运行docker-compose时,我收到以下错误:

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;

 ...
 ...

码头工人,compose.yml:

version: '3'

services:

  backend:
    build: ./nginx
    depends_on:
    - db
    - redis
    working_dir: /var/www
    volumes:
      - ../../src:/var/www
    ports:
      - 80:80
...
...
docker nginx
2个回答
1
投票

这意味着您没有正确设置ssl(您缺少服务器证书)。由于你已经在docker-compose中映射了端口80而不是443,我假设你不打算使用SSL。

只需删除nginx.conf中的以下行以禁用ssl:

listen 443 ssl http2;

一定要重建并重新启动你的nginx容器。


0
投票

你有没有其他服务器在端口443上侦听。尝试从/ etc / nginx / sites-enabled中删除所有符号链接,除了你想要工作的这个服务器