New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using RocketChat Docker's image behind a proxy (nginx-letsencrypt-companion) #9210

Closed
Julianoe opened this Issue Dec 21, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@Julianoe

Julianoe commented Dec 21, 2017

Hi guys!

this is a crosspost to this issue RocketChat/Docker.Official.Image#38 because i fear it would lack visibility
I'm willing to contribute to document this if i find a working solution.

note:

  • i'm running a Ubuntu Xenial install
  • i managed to get RocketChat running on it's own before following these instructions
  • when accessing my ip x.x.x.x:3000 i successfully get the rocketchat login screen so it's obviously the networking that grips

I'm trying to make a RocketChat instance work in parallel with other services (i plan to have rocket+nextcloud on a server) with letsencrypt-nginx-proxy-companion. I've already managed to use this tool on another project to run multiple Wordpress/mysql installs on the same server.

Here are the two files i use

docker-compose.yml for RocketChat

version: '3.3'

services:
  db:
    image: mongo
    volumes:
      - ./datatest/runtime/db:/data/db
      - ./datatest/dump:/dump
    command: mongod --smallfiles

  rocketchat:
    image: rocketchat/rocket.chat:latest
    environment:
      MONGO_URL: mongodb://db:27017/rocketchat
      ROOT_URL: http://sub.mydomain.fr
      Accounts_UseDNSDomainCheck: "true"
      MAIL_URL: smtp://contact@mymail.com
      Accounts_UseDNSDomainCheck: "false"
      VIRTUAL_HOST: sub.mydomain.fr
      LETSENCRYPT_HOST: sub.mydomain.fr
      LETSENCRYPT_EMAIL: myemail@gmail.com
    links:
      - db:db
    ports:
      - 3000:3000
    restart: always
  hubot:
    # doesnt matter for now
networks:
    default:
       external:
         name: mywebproxy

docker-compose-yml for the proxy

version: '3.3'
services:
  nginx-web:
    image: nginx
    labels:
        com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    container_name: ${NGINX_WEB}
    restart: always
    ports:
      - "${IP}:80:80"
      - "${IP}:443:443"
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
      - ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro

  nginx-gen:
    image: jwilder/docker-gen
    command: -notify-sighup ${NGINX_WEB} -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    container_name: ${DOCKER_GEN}
    restart: always
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
      - ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro

  nginx-letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: ${LETS_ENCRYPT}
    restart: always
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN}
      NGINX_PROXY_CONTAINER: ${NGINX_WEB}

networks:
  default:
    external:
      name:mywebproxy

Any idea? I think that could be a great thing to have a working way of doing this for everyone. It would facilitate a lot for people wanting to run RocketChat along other services (a website/a cloud) that run via Docker.

@Julianoe

This comment has been minimized.

Show comment
Hide comment
@Julianoe

Julianoe Dec 21, 2017

Ok i solved this. By using https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion it makes things easy. Don't forget to set Accounts_UseDNSDomainCheck: "false" : i'm not too sure why it's necessary but it seem to work like this :)

With this type of config you can run multiple RocketChat instances with Docker or use RocketChat alongside a website (or several websites) or other cloud services, like NextCloud for example. Refer to great @evertramos repos for that :) (i've not tried it out but i will soon.

docker-compose.yml for RocketChat

version: '3.3'

services:
  db:
    image: mongo
    volumes:
      - ./datatest/runtime/db:/data/db
      - ./datatest/dump:/dump
    command: mongod --smallfiles

  rocketchat:
    image: rocketchat/rocket.chat:latest
    environment:
      MONGO_URL: mongodb://db:27017/rocketchat
      ROOT_URL: http://sub.mydomain.fr
      Accounts_UseDNSDomainCheck: "false"
      MAIL_URL: smtp://contact@mymail.com
      VIRTUAL_HOST: sub.mydomain.fr
      LETSENCRYPT_HOST: sub.mydomain.fr
      LETSENCRYPT_EMAIL: myemail@gmail.com
    links:
      - db:db
    ports:
      - 3000:3000
    restart: always
  hubot:
    # doesnt matter for now
networks:
    default:
       external:
         name: mywebproxy

docker-compose-yml for the proxy

I'm using the docker-compose and .env files https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion. It allows you to launch a proxy very quickly and easily that also gives you SSL on your domains.

version: '3.3'
services:
  nginx-web:
    image: nginx
    labels:
        com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    container_name: ${NGINX_WEB}
    restart: always
    ports:
      - "${IP}:80:80"
      - "${IP}:443:443"
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
      - ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro

  nginx-gen:
    image: jwilder/docker-gen
    command: -notify-sighup ${NGINX_WEB} -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    container_name: ${DOCKER_GEN}
    restart: always
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
      - ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro

  nginx-letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: ${LETS_ENCRYPT}
    restart: always
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN}
      NGINX_PROXY_CONTAINER: ${NGINX_WEB}

networks:
  default:
    external:
      name:mywebproxy

Julianoe commented Dec 21, 2017

Ok i solved this. By using https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion it makes things easy. Don't forget to set Accounts_UseDNSDomainCheck: "false" : i'm not too sure why it's necessary but it seem to work like this :)

With this type of config you can run multiple RocketChat instances with Docker or use RocketChat alongside a website (or several websites) or other cloud services, like NextCloud for example. Refer to great @evertramos repos for that :) (i've not tried it out but i will soon.

docker-compose.yml for RocketChat

version: '3.3'

services:
  db:
    image: mongo
    volumes:
      - ./datatest/runtime/db:/data/db
      - ./datatest/dump:/dump
    command: mongod --smallfiles

  rocketchat:
    image: rocketchat/rocket.chat:latest
    environment:
      MONGO_URL: mongodb://db:27017/rocketchat
      ROOT_URL: http://sub.mydomain.fr
      Accounts_UseDNSDomainCheck: "false"
      MAIL_URL: smtp://contact@mymail.com
      VIRTUAL_HOST: sub.mydomain.fr
      LETSENCRYPT_HOST: sub.mydomain.fr
      LETSENCRYPT_EMAIL: myemail@gmail.com
    links:
      - db:db
    ports:
      - 3000:3000
    restart: always
  hubot:
    # doesnt matter for now
networks:
    default:
       external:
         name: mywebproxy

docker-compose-yml for the proxy

I'm using the docker-compose and .env files https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion. It allows you to launch a proxy very quickly and easily that also gives you SSL on your domains.

version: '3.3'
services:
  nginx-web:
    image: nginx
    labels:
        com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true"
    container_name: ${NGINX_WEB}
    restart: always
    ports:
      - "${IP}:80:80"
      - "${IP}:443:443"
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
      - ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro

  nginx-gen:
    image: jwilder/docker-gen
    command: -notify-sighup ${NGINX_WEB} -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
    container_name: ${DOCKER_GEN}
    restart: always
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:ro
      - ${NGINX_FILES_PATH}/htpasswd:/etc/nginx/htpasswd:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro

  nginx-letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: ${LETS_ENCRYPT}
    restart: always
    volumes:
      - ${NGINX_FILES_PATH}/conf.d:/etc/nginx/conf.d
      - ${NGINX_FILES_PATH}/vhost.d:/etc/nginx/vhost.d
      - ${NGINX_FILES_PATH}/html:/usr/share/nginx/html
      - ${NGINX_FILES_PATH}/certs:/etc/nginx/certs:rw
      - /var/run/docker.sock:/var/run/docker.sock:ro
    environment:
      NGINX_DOCKER_GEN_CONTAINER: ${DOCKER_GEN}
      NGINX_PROXY_CONTAINER: ${NGINX_WEB}

networks:
  default:
    external:
      name:mywebproxy

@Julianoe Julianoe closed this Dec 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment