Reputation: 1
I have the root folder of the Vue project, which consists of 2 folders backend and frontend with their own dockerfile, docker-compose is at the root. I need to configure it to receive certificates for my domain where the portainer is located. I do not have access to the administrator account in the portainer and I do not have ssh access to the server. The domain and server with portainer were configured by the system administrator and gave me a username and password to access portainer. My question is: can I use only portainer to set up certificates for the domain and the operation of my vue application. Now I use http for beck and have access to all the functionality of the application, including the frontend via http://mydomain if I use https, I get an error with certificates. Can I set up automatic receipt and installation of certificates only through the portainer functionality??? I understand that in all files I need to replace http with https, the question is to configure certificates.
My CORS:
app.use(cors({
origin: [
'http://mydomain',
'https://mydomain',
]
}));
My vue.app.config (I understand that https needs to be enabled)
module.exports = {
configureWebpack: {
devtool: "source-map"
},
devServer: {
https: false, // Отключаем HTTPS
host: '0.0.0.0', // Используем 0.0.0.0 для доступа с других устройств в сети
port: 80 // Укажите порт, который вы хотите использовать
}
};
My dockerfile for backend:
FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3002
CMD ["npm", "start"]
My dockerfile for frontend:
FROM node:18 as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx as production-stage
COPY --from=build-stage /app/dist /app
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
My nginx.conf
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name afishka.pspu.ru;
location / {
root /app;
index index.html;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
My docker-compose:
services:
db:
image: postgres:16
container_name: db
environment:
POSTGRES_DB: ***
POSTGRES_USER: ***
POSTGRES_PASSWORD: ***
volumes:
- db_data_16:/var/lib/postgresql/data
ports:
- "5433:5432"
networks:
-app-network
backend:
image: myname/mybackcontainer
container_name: backend
ports:
- "3002:3002"
environment:
PORT: 3002
SECRET: ***
DATABASE_URL: ***
depends_on:
- db
networks:
-app-network
frontend:
image: myname/myfrontcontainer
container_name: front
ports:
- "80:80"
environment:
VUE_APP_SERVER: http://mydomain:3002
depends_on:
- backend
networks:
-app-network
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: ***
PGADMIN_DEFAULT_PASSWORD: ***
ports:
- "8081:80"
networks:
- app-network
depends_on:
- db
volumes:
db_data_16:
networks:
app-network:
driver: bridge
I tried to add nginx proxy with letsencrypt-nginx-proxy-companion:
version: '3'
services:
nginx-proxy:
image: jwilder/nginx-proxy
container_name: nginx-proxy
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/tmp/docker.sock:ro
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
networks:
- app-network
letsencrypt-nginx-proxy-companion:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- certs:/etc/nginx/certs
- vhost:/etc/nginx/vhost.d
- html:/usr/share/nginx/html
depends_on:
- nginx-proxy
networks:
-app-network
db:
image: postgres:16
container_name: db
environment:
POSTGRES_DB: db1233
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- db_data_16:/var/lib/postgresql/data
ports:
- "5433:5432"
networks:
- webafishka_app-network
backend:
image: myname/mybackcontainer
container_name: backend
ports:
- "3002:3002"
environment:
PORT: 3002
SECRET: 'sadfghkjlhdfsa'
DATABASE_URL: postgres://postgres:postgres@db:5432/db1233
depends_on:
- db
networks:
- app-network
frontend:
image: myname/myfrontcontainer
container_name: front
ports:
- "80:80"
environment:
VUE_APP_SERVER: http://mydomain:3002
VIRTUAL_HOST: yourdomain.com
LETSENCRYPT_HOST: yourdomain.com
LETSENCRYPT_EMAIL: [email protected]
depends_on:
- backend
networks:
- app-network
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "8081:80"
networks:
- app-network
depends_on:
- db
volumes:
db_data_16:
certs:
vhost:
html:
networks:
app-network:
driver: bridge
with the corresponding variables in my docker-compose, but I received errors with email and the existence of some directories. I do not fully understand whether I can set up an https connection for my application without contacting the system administrator and additional resources, and whether I need to register with any platforms.
Upvotes: 0
Views: 26