Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Looking for docker-compose complete example w/ rev. proxy #12

Closed
jacobpdq opened this issue Apr 10, 2018 · 7 comments
Closed

Looking for docker-compose complete example w/ rev. proxy #12

jacobpdq opened this issue Apr 10, 2018 · 7 comments

Comments

@jacobpdq
Copy link

What I've got isn't hooking in to your compose file; could you provide a complete example using compose?

`version: "2"

services:
nginx:
restart: always
image: nginx
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/conf.d"
- "/etc/nginx/vhost.d"
- "/usr/share/nginx/html"
- "./volumes/proxy/certs:/etc/nginx/certs:ro"

nginx-gen:
restart: always
image: jwilder/docker-gen
container_name: nginx-gen
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "./volumes/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf

letsencrypt-nginx-proxy-companion:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes_from:
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./volumes/proxy/certs:/etc/nginx/certs:rw"
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen

networks:
proxy-tier:
external:
name: nginx-proxy`

@tiredofit
Copy link
Owner

Here's what we use with great success.

version: '2.1'

services:
  redacted-nginx-proxy:
    image: nginx-proxy:938d638e5c4d0dd98105bb15838cb5481de70a80
    container_name: redacted-nginx-proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./conf/vhost.d:/etc/nginx/vhost.d
      - ./conf/html:/usr/share/nginx/html
      - ./conf/certs:/etc/nginx/certs:ro
      - ./logs:/var/log/nginx
      - /var/run/docker.sock:/tmp/docker.sock:ro
    environment:
      - ZABBIX_HOSTNAME=redacted-nginx-proxy
    networks:
      - proxy-tier
    restart: always
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"


  redacted-letsencrypt-companion:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: redacted-letsencrypt-companion
    volumes_from:
      - redacted-nginx-proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./conf/certs:/etc/nginx/certs:rw
    restart: always
  
networks:
  proxy-tier:
    external:
      name: nginx-proxy

@jacobpdq
Copy link
Author

jacobpdq commented Apr 10, 2018

Thanks. And just before I pull the trigger, does this make sense

version: '2'

services:
  freepbx-app:
    container_name: freepbx-app
    image: tiredofit/freepbx
    ports:
     #### If you aren't using a reverse proxy
     #- 80:80
     #### If you want SSL Support and not using a reverse proxy
     #- 443:443
      - 5060:5060
      - 5160:5160
      - 18000-18100:18000-18100/udp
    volumes:
      - ./certs:/certs
      - ./data:/data
      - ./logs:/var/log
      - ./data/www:/var/www/html
     ### Only Enable this option below if you set DB_EMBEDDED=TRUE
     #- ./db:/var/lib/mysql

    environment: 
      - VIRTUAL_HOST=████
      - VIRTUAL_NETWORK=nginx-proxy
     ### If you want to connect to the SSL Enabled Container 
     #- VIRTUAL_PORT=443
     #- VIRTUAL_PROTO=https
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=████
      - LETSENCRYPT_EMAIL=████

      - ZABBIX_HOSTNAME=freepbx-app

      - RTP_START=18000
      - RTP_FINISH=18100
    
     ## Use for External MySQL Server
     #- DB_EMBEDDED=FALSE

     ### These are only necessary if DB_EMBEDDED=FALSE
      #- DB_HOST=freepbx-db
      #- DB_PORT=3306
      #- DB_NAME=asterisk
      #- DB_USER=asterisk
      #- DB_PASS=asteriskpass
    
     ### If you are using TLS Support for Apache to listen on 443 in the container drop them in /certs and set these:
     #- TLS_CERT=cert.pem
     #- TLS_KEY=key.pem
     
    restart: always
    networks:
      - proxy-tier
    ### These final lines are for Fail2ban. If you don't want, comment and also add ENABLE_FAIL2BAN=FALSE to your environment
    cap_add:
      - NET_ADMIN
    privileged: true

  freepbx-db:
    container_name: freepbx-db
    image: tiredofit/mariadb
    restart: always
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=asterisk
      - MYSQL_USER=asterisk
      - MYSQL_PASSWORD=asteriskpass
    networks:
      - proxy-tier

  freepbx-db-backup:
    container_name: freepbx-db-backup
    image: tiredofit/db-backup
    links:
     - freepbx-db
    volumes:
      - ./dbbackup:/backup
    environment:
      - ZABBIX_HOSTNAME=freepbx-db-backup
      - DB_HOST=freepbx-db
      - DB_TYPE=mariadb
      - DB_NAME=asterisk
      - DB_USER=asterisk
      - DB_PASS=asteriskpass
      - DB_DUMP_FREQ=1440
      - DB_DUMP_BEGIN=0000
      - DB_CLEANUP_TIME=8640
      - COMPRESSION=BZ
      - MD5=TRUE
    networks:
      - proxy-tier
    restart: always

networks:
  proxy-tier:
    external:
      name: nginx-proxy

@jacobpdq
Copy link
Author

jacobpdq commented Apr 10, 2018

edit: commented 80

... do I have to use expose: - 80?

@tiredofit
Copy link
Owner

Looks like you are going to use the embedded DB, so you'll want to uncomment the part where it says:

### Only Enable this option below if you set DB_EMBEDDED=TRUE
     #- ./db:/var/lib/mysql

You'll want to get rid of the containers (freepbx-db and freepbx-db-backup) though. I use the external DB (non embedded) and added it the internal DB feature "because I could", but don't have much experience with using it in this docker image. Personally I like to seperate them.

@jacobpdq
Copy link
Author

I see. I guess I should set that up and stick with what works, then. Thanks +1+1

@tiredofit
Copy link
Owner

tiredofit commented Apr 10, 2018

Good luck! We're succesfully using this on a development server (calling working, webrtc phone working) with a planned usage case of over 500 extensions in the next 60 days, so updates to this image will come in bursts as I add more settings. I'm currently on the hunt on how to get LDAP authentication to work for the user manager and plan to have an ability to inject custom themes / tweaks without having to modify the image shortly. Also, I usually build complicated images in Debian first and then switch over to Alpine after the fact. The Alpine image is 80% complete and 1/4 of the size..

@jacobpdq
Copy link
Author

Very cool. No matter for me since I have 2 extensions and at most ~5 concurrent calls. Keep up the good work – I'll let you know if I have any questions; many thanks for answering

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants