Nginx docker 容器停止工作

Nginx docker 容器停止工作

第一次使用 Nginx,不知道为什么我的容器突然停止工作。

我使用来自 docker images 的 nginx 映像,在启用 https 之前它可以正常工作。

这是我添加到镜像中的 nginx.conf 文件,用于与我的 nginx 容器创建 https/SSL 连接

#file used to configure https server with self-signed certificated. this file is used by azure/docker-scripts/docker-e2e-group.yaml
server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
#https://localhost
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name localhost;

    server_tokens off;

    ssl_certificate /etc/nginx/conf.d/ssl.crt;
    ssl_certificate_key /etc/nginx/conf.d/ssl.key;

    ssl_buffer_size 8k;

    # ssl_dhparam /etc/ssl/certs/dhparam-2048.pem; can use a pem file here.

    ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
    ssl_prefer_server_ciphers on;

    ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

    ssl_ecdh_curve secp384r1;
    ssl_session_tickets off;

    # OCSP stapling
    # ssl_stapling on;
    # ssl_stapling_verify on;
    # resolver 8.8.8.8;

    #return 301 https://localhost$request_uri;
     location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Dockerfile 分为两个步骤,第一步这里省略,但我只编译我的角度应用程序。第二步。

### STAGE 2: Run ###
FROM nginx:1.17.1-alpine
COPY --from=build /app/dist /usr/share/nginx/html/

几分钟后,容器拒绝任何连接并且不再为网站提供服务。

任何故障排除帮助都将不胜感激。现在甚至不知道该看什么了。

相关内容