MKCERT Docker
Dockerfile ../Dockerfile
FROM nginx:alpine AS runtime
COPY ssl /etc/nginx/ssl
COPY conf.d /etc/nginx/conf.d
EXPOSE 443
Terminal INSTALL
sudo apt install mkcert libnss3-tools docker.io
sudo groupadd docker
sudo usermod -aG docker $USER
# sudo reboot
mkdir -p ssl conf.d
mkcert -install
mkcert *.domain.dev domain.dev
mv _wildcard.domain.dev* ssl
sudo nano /etc/hosts
Config Hosts /etc/hosts
127.0.0.1 sub.domain.dev
127.0.0.1 domain.dev
Nginx ../conf.d/
# FILE: conf.d/sub.domain.dev.conf
server {
server_name sub.domain.dev;
location / {
proxy_pass http://127.0.0.1:3000/;
}
location /api/ {
proxy_pass https://domain.dev/api/;
}
location /auth/ {
proxy_pass https://domain.dev/auth/;
}
location /documents/ {
proxy_pass https://domain.dev/documents/;
}
location /ws {
proxy_pass http://127.0.0.1:3000/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/_wildcard.domain.dev+1.pem;
ssl_certificate_key /etc/nginx/ssl/_wildcard.domain.dev+1-key.pem;
}
# FILE: conf.d/domain.dev.conf
server {
server_name domain.dev;
location / {
proxy_pass http://127.0.0.1:5000/;
}
location /ws {
proxy_pass http://127.0.0.1:5000/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/_wildcard.domain.dev+1.pem;
ssl_certificate_key /etc/nginx/ssl/_wildcard.domain.dev+1-key.pem;
}
Terminal BUILD and RUN
docker build -t domaindev . && docker image prune --filter="dangling=true"
docker run --rm --net=host --name domaindev -it domaindev
# docker run -d --restart always --net=host --name domaindev -it domaindev