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

标签 docker nginx

运行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;

 ...
 ...

docker-compose.yml:
version: '3'

services:

  backend:
    build: ./nginx
    depends_on:
    - db
    - redis
    working_dir: /var/www
    volumes:
      - ../../src:/var/www
    ports:
      - 80:80
...
...

最佳答案

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

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

listen 443 ssl http2;

确保重建并重新启动您的nginx容器。

关于docker - docker-compose up对于nginx容器失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55894864/

相关文章:

docker - 在Docker中运行OS(Ubuntu)有什么意义?

docker - SonarQube Docker 安装 CorruptIndexException : checksum failed

redirect - NGINX - 返回 301 与重写

mysql - MySQL 的 Docker 代理 : "Lost connection" message from host machine

nginx - Nginx proxy_pass:是否可以在URL中添加静态参数?

javascript - Node + socket.io 与 nginx 正确设置

Dockerfile : not able to run bin command ubuntu

linux - Docker awslogs 给出错误 NoCredentialProviders

docker - Github 操作 : Push docker image build by gradle task

docker - 如何将 Nginx 容器连接到我的 React 容器?