【问题标题】:cannot load certificate "/etc/ssl/ServerCertificate.crt": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory无法加载证书“/etc/ssl/ServerCertificate.crt”:BIO_new_file() 失败(SSL:错误:02001002:系统库:fopen:没有这样的文件或目录
【发布时间】:2021-08-03 13:33:29
【问题描述】:

这是我的 docker 文件

# stage1 - build react app first 

FROM node:12.16.1-alpine3.9 as build

WORKDIR /app

ENV PATH /app/node_modules/.bin:$PATH

COPY ./package.json /app/

COPY ./package-lock.json /app/

RUN npm i --silent

COPY . /app

RUN npm run build



# stage 2 - build the final image and copy the react build files

FROM nginx:1.17.8-alpine

COPY --from=build /app/build /usr/share/nginx/html

RUN rm /etc/nginx/conf.d/default.conf

COPY nginx/nginx.conf /etc/nginx/conf.d
COPY ServerCertificate.crt /etc/ssl/
COPY 2022pk.key /etc/ssl/



EXPOSE 443

CMD ["nginx", "-g", "daemon off;"]

这个在 nginx.conf 文件中

server {



  listen 443 ssl;
  ssl_certificate /etc/ssl/ServerCertificate.crt;
  ssl_certificate_key /etc/ssl/2022pk.key;
  server_name *.com;



  location / {

    root   /usr/share/nginx/html;

    index  index.html index.htm;



    # to redirect all the requests to index.html, 

    # useful when you are using react-router



    try_files $uri /index.html; 

  }



  error_page   500 502 503 504  /50x.html;



  location = /50x.html {

    root   /usr/share/nginx/html;

  }



}


我遇到错误

无法加载证书“/root/etc/ssl/ServerCertificate.crt”:BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/root/etc/ssl /ServerCertificate.crt','r') error:2006D080:BIO routines:BIO_new_file:no such file)

【问题讨论】:

    标签: docker nginx https dockerfile nginx-reverse-proxy


    【解决方案1】:

    在 Expose 中添加了 80 端口,它工作了!!

    【讨论】:

    • 曝光是什么意思?谢谢。
    猜你喜欢
    • 2014-04-08
    • 2021-03-04
    • 2020-08-15
    • 2021-07-10
    • 2016-12-27
    • 1970-01-01
    • 2014-03-19
    • 2016-07-26
    • 2019-01-22
    相关资源
    最近更新 更多