Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save alexandre2602/3f60d245aa0d4193f357833d48a8a0c5 to your computer and use it in GitHub Desktop.
Save alexandre2602/3f60d245aa0d4193f357833d48a8a0c5 to your computer and use it in GitHub Desktop.

Revisions

  1. @w33ble w33ble revised this gist Feb 8, 2020. 2 changed files with 64 additions and 3 deletions.
    63 changes: 63 additions & 0 deletions docker-compose.advanced.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,63 @@
    version: '3'

    services:
    nginx-proxy:
    image: nginx:alpine
    container_name: proxy-nginx
    environment:
    - DEFAULT_HOST=hello.local
    ports:
    - 80:80
    - 443:443
    volumes:
    - conf:/etc/nginx/conf.d:ro
    - vhost:/etc/nginx/vhost.d:ro
    - html:/usr/share/nginx/html:ro
    - certs:/etc/nginx/certs:ro

    dockergen:
    image: jwilder/docker-gen
    container_name: proxy-dockergen
    command: -notify-sighup proxy-nginx -wait 5s:30s -watch /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    - ./templates:/etc/docker-gen/templates:rw # curl -o templates/nginx.tmpl https://raw.githubusercontent.com/jwilder/nginx-proxy/master/nginx.tmpl
    - conf:/etc/nginx/conf.d
    - vhost:/etc/nginx/vhost.d:ro
    - html:/usr/share/nginx/html
    - certs:/etc/nginx/certs:ro
    environment:
    - DEFAULT_HOST=hello.local

    letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: proxy-letsencrypt
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro
    - ./templates:/etc/docker-gen/templates:ro
    - conf:/etc/nginx/conf.d
    - vhost:/etc/nginx/vhost.d
    - html:/usr/share/nginx/html
    - certs:/etc/nginx/certs
    environment:
    - [email protected]
    - NGINX_PROXY_CONTAINER=proxy-nginx
    - NGINX_DOCKER_GEN_CONTAINER=proxy-dockergen

    hello:
    image: nginx:alpine
    environment:
    - VIRTUAL_HOST=hello.local
    volumes:
    - ./index.html:/usr/share/nginx/html/index.html

    networks:
    default:
    external:
    name: nginx-proxy

    volumes:
    conf:
    certs:
    vhost:
    html:
    4 changes: 1 addition & 3 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -16,10 +16,8 @@ services:
    - /var/run/docker.sock:/tmp/docker.sock:ro

    hello:
    image: nginx:1-alpine
    image: nginx:alpine
    environment:
    - VIRTUAL_HOST=hello.local
    volumes:
    - ./index.html:/usr/share/nginx/html/index.html
    ports:
    - 8080:80
  2. @w33ble w33ble revised this gist Feb 8, 2020. 3 changed files with 14 additions and 8 deletions.
    13 changes: 10 additions & 3 deletions docker-compose.app.yml
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,13 @@ version: '3'

    services:
    thing:
    # in order for the proxy to see this service, it needs to be on the same network
    networks:
    - nginx_nginx-proxy
    image: jwilder/whoami
    environment:
    - VIRTUAL_PORT=8000
    - VIRTUAL_HOST=whoami.local

    # in order for the proxy to see this service, it needs to be on the same network
    networks:
    default:
    external:
    name: nginx-proxy
    8 changes: 3 additions & 5 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    version: '3'

    networks:
    nginx-proxy:
    default:
    external:
    name: nginx-proxy

    services:
    nginx-proxy:
    @@ -12,8 +14,6 @@ services:
    - 80:80
    volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
    - nginx-proxy

    hello:
    image: nginx:1-alpine
    @@ -23,5 +23,3 @@ services:
    - ./index.html:/usr/share/nginx/html/index.html
    ports:
    - 8080:80
    networks:
    - nginx-proxy
    1 change: 1 addition & 0 deletions shell.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    $ curl -H "Host: whoami.local" localhost
  3. @w33ble w33ble revised this gist Jan 3, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion docker-compose.app.yml
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@ version: '3'

    services:
    thing:
    # in order for the proxy to see
    # in order for the proxy to see this service, it needs to be on the same network
    networks:
    - nginx_nginx-proxy
  4. @w33ble w33ble created this gist Jan 3, 2020.
    7 changes: 7 additions & 0 deletions docker-compose.app.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    version: '3'

    services:
    thing:
    # in order for the proxy to see
    networks:
    - nginx_nginx-proxy
    27 changes: 27 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    version: '3'

    networks:
    nginx-proxy:

    services:
    nginx-proxy:
    image: jwilder/nginx-proxy
    environment:
    - DEFAULT_HOST=hello.local
    ports:
    - 80:80
    volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
    - nginx-proxy

    hello:
    image: nginx:1-alpine
    environment:
    - VIRTUAL_HOST=hello.local
    volumes:
    - ./index.html:/usr/share/nginx/html/index.html
    ports:
    - 8080:80
    networks:
    - nginx-proxy