L
L
luckyjenro02022-03-31 19:37:03
Nginx
luckyjenro0, 2022-03-31 19:37:03

How to put ssl on nginx/docker/vue?

There is an application, here are the run files:

DockerFile:

FROM node:15.10.0 as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install && npm cache clean --force
COPY ./ .
RUN npm run build

FROM nginx as production-stage
RUN mkdir /app
COPY --from=build-stage /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 9080
CMD ["nginx", "-g", "daemon off;"]

There is also nginx.conf in the site folder:

server {
    location / {
      root   /app;
      index  index.html;
      try_files $uri $uri/ /index.html;
    }
    error_page   500 502 503 504  /50x.html;
    server_name blamegrief.ru www.blamegrief.ru;

    location = /50x.html {
      root   /var/www/html;
    }

    listen                9080;
    server_name           blamegrief.ru;

    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

    ssl_certificate /etc/letsencrypt/live/blamegrief.ru/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/blamegrief.ru/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  }

By running first docker build . -t my-app, then docker run -p 80:9080 my-app, and then curl localhost:80.

Question: how to make SSL? I've been suffering for 2 days, now I'm writing that for some reason the certificate files were not found (I don't see anything at all), I tried to put /root/ before /etc/, I went all over stakcoverflow...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2022-03-31
@luckyjenro0

I've been suffering for 2 days, right now it says that for some reason they were not found

Certainly not found. The contents of the container are isolated from the host system (this is the whole point), so if the /etc/letsencrypt directory is not mounted into the container, Nginx will not be able to access the certificates in any way.
docker run --rm -v /etc/letsencrypt:/etc/letsencrypt -p 80:9080 my-app

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question