The first step is to make the Node Server docker-like, adding a Dockerfile directly to the project. The configuration file for nginx is as follows

server {

listen 80; server_name example.org; server_tokens off; location /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 } } server {

listen 443 ssl; server_name example.org; server_tokens off; ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; location / { proxy_pass proxy_set_header Host httphost; ProxysetheaderX – Real – IPhttp_host; proxy_set_header X-Real-IP httphost; ProxysetheaderX – Real – IPremote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }} We now have a Nginx page tour Server with a valid certificate, Node Server after Nginx is done. We directly made some modifications to the docker-comemage.yml provided in the previous Boilerplate. If relative electron has more intuitive understanding, it can also refer to its format as follows:

Swam: page www.pizei.com

version: “3” services: nodeapp:

Image: nodeserver:1.0.0 container_name: nodeapp restart: Unless – Stopped volumes:

  • /data/usersFolder:/server/config

ports:

  • “3000:3000”

networks:

  • app-network

nginx:

Image: nginx:1.15-alpine Container_name: nginx_server restart: Unless – Stopped volumes:

  • . / data/nginx: / et page www.pizei.comc/nginx/conf.d
  • ./data/certbot/conf:/etc/letsencrypt
  • ./data/certbot/www:/var/www/certbot

ports:

  • “80:80”
  • “443:443”

networks:

  • app-network

command: ‘/bin/sh -c ”while :; do sleep 6h & wait $${! }; nginx -s reload; done & nginx -g “daemon off;” ”’ certbot:

image: certbot/certbot restart: unless-stopped container_name: certbot_one volumes:

  • ./data/certbot/conf:/etc/letsencrypt
  • ./data/certbot/www:/var/www/certbot

entrypoint: “/bin/sh -c ‘trap exit TERM; while :; do certbot renew; sleep 12h & wait $${! }; done; ‘” networks: app-network:

Driver: Bridge creates a network to allow Nginx to communicate directly with the Node server. Nginx conf can also be written smoothly. I remember using -link to communicate between containers, but the official recommendation is to create a network