【发布时间】: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