NGINX and LetsEncrypt

Just another WordPress site

NGINX and LetsEncrypt

As you can read in the blogs, the internet is a nasty place, so you need protection. And one of the first defenses is HTTPS. Also you probably will have multiple dockers using port 80/443, so you need NGINX as well. The below shown compose file will create these two dockers with an automated refresh of the keys.

version: '3'

services:
    nginx-proxy:
        image: jwilder/nginx-proxy:alpine
        restart: "always"
        container_name: Nginx
        ports:
         - "80:80"
         - "443:443"
        networks:
         - nginx-proxy
        labels:
         - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" # Label needed for Let's Encrypt companion container
        volumes:
         - /var/run/docker.sock:/tmp/docker.sock:ro
         - "./nginx-conf:/etc/nginx/conf.d"
         - "./nginx-vhost:/etc/nginx/vhost.d"
         - "./html:/usr/share/nginx/html"
         - "./certs:/etc/nginx/certs:ro"
    letsencrypt-nginx-proxy-companion:
        image: jrcs/letsencrypt-nginx-proxy-companion
        restart: always
        container_name: Letsencrypt
        volumes:
         - "/var/run/docker.sock:/var/run/docker.sock:ro"
         - "./nginx-conf:/etc/nginx/conf.d"
         - "./nginx-vhost:/etc/nginx/vhost.d"
         - "./html:/usr/share/nginx/html"
         - "./certs:/etc/nginx/certs:rw"
        depends_on:
            - nginx-proxy

networks:
    nginx-proxy:
        external:
            name: proxy_nginx

Leave a Reply

Your email address will not be published. Required fields are marked *