Skip to content

jgcl/docker-nginx-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Docker Nginx Proxy

A simple example of how to use the Docker Nginx Proxy as a simple router that can connect to LetsEncrypt and provide free SSL certificate.

I used the following images and projects:

See docker-compose.yml file:

version: "3.3"

services:
  whoami:
    container_name: whoami
    image: containous/whoami
    restart: unless-stopped
    network_mode: "bridge"
    environment:
      - VIRTUAL_HOST=whoami.localhost,whoami.joaogabriel.org
      - LETSENCRYPT_HOST=whoami.joaogabriel.org
      - LETSENCRYPT_EMAIL=gabriel@joaogabriel.org

  nginx_proxy:
    container_name: nginx_proxy
    image: jwilder/nginx-proxy:alpine
    volumes:
      - nginx_proxy_nginx_certs:/etc/nginx/certs
      - nginx_proxy_nginx_vhost_d:/etc/nginx/vhost.d
      - nginx_proxy_nginx_html:/usr/share/nginx/html
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: unless-stopped
    network_mode: "bridge"
    environment:
      - ENABLE_IPV6=true
      - DEFAULT_HOST=whoami.joaogabriel.org
    ports:
      - 80:80
      - 443:443

  lets_encrypt:
    container_name: lets_encrypt
    image: jrcs/letsencrypt-nginx-proxy-companion
    volumes:
      - nginx_proxy_nginx_certs:/etc/nginx/certs
      - nginx_proxy_nginx_vhost_d:/etc/nginx/vhost.d
      - nginx_proxy_nginx_html:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      - NGINX_PROXY_CONTAINER=nginx_proxy
    restart: unless-stopped
    network_mode: "bridge"
    depends_on:
      - nginx_proxy

volumes:
  nginx_proxy_nginx_certs:
  nginx_proxy_nginx_vhost_d:
  nginx_proxy_nginx_html:

The volumes are used to persist SSL certificates (do this because LetsEncrypt has a rate limit).

Another option

Another option is to use Traefik, a more complete proxy with a dashboard included. https://github.com/jgcl/docker-traefik-proxy

Releases

No releases published

Packages

No packages published