L
L
letema2018-09-27 10:14:38
Nginx
letema, 2018-09-27 10:14:38

How to set up Docker and dynamic subdomains?

Good afternoon. There is a task. There is a project with docker that will be deployed from the git branch to the server. It is necessary that the subdomain is assigned to the application automatically. For example *.dev.domen.ru. As I understand it, you can do this through nginx-proxy. But something doesn't work. Here is my docker-compose

version: '3'
services:
nginx:
image: nginx:1.10
env_file: .env
ports:
- 8090:80
networks:
- confluence
- proxy
environment:
VIRTUAL_HOST: 'develop.dev.domen.ru'
VIRTUAL_PORT: '8090'
volumes:
- ".:/var/www"
- "./env/nginx/nginx.conf:/etc/nginx/nginx.conf"
- "./env/nginx/conf.d:/etc/nginx/conf.d"
- "./env/var/log/nginx:/var/log/nginx"
proxy:
image: jwilder/nginx-proxy
ports:
- 0.0.0.0:8090
volumes:
- /var/run/docker.sock:/tmp/docker.sock
networks:
- proxy
depends_on:
- app
app:
build: ./env
expose:
- 9000
ports:
- 11080:11080
volumes:
- ".:/var/www"
- "./env/php/www.conf:/etc/php/7.1/fpm/pool.d/www.conf"
- "./env/supervisor:/etc/supervisor"
- "./env/crontab.conf:/etc/crontab.conf"
- "./env/var/log/supervisor:/var/log/supervisor"
entrypoint:
- "/usr/bin/supervisord"
- "-c"
- "/etc/supervisor/supervisord.conf"
depends_on:
- mysql
- redis
mysql:
image: mysql:5.7
env_file: .env
environment:
MYSQL_ROOT_PASSWORD: ''
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
ports:
- 3306:3306
volumes:
- ./env/mysql/my.cnf:/etc/mysql/conf.d/1bom.cnf
- ./env/var/lib/mysql:/var/lib/mysql
redis:
image: redis
ports:
- 6379:6379
volumes:
- ./env/var/redis:/data

Can you suggest what is the reason?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-09-27
@q2digger

Why do you need another proxy before jwilder/nginx-proxy ?
See, here is a really working docker-compose with nginx-proxy + confluence + postgress:

version: '2'

services:
  confluence:
    image: q2digger/confluence:latest
    container_name: confluence
    hostname: confluence
    volumes:
      - app_data:/var/atlassian/application-data/confluence
    restart: always
    ports:
      - 8090:8090
      - 8091:8091
    networks:
      - confluence
      - proxy
    environment:
      JVM_MINIMUM_MEMORY: '2048m'
      JVM_MAXIMUM_MEMORY: '4096m'
      CATALINA_CONNECTOR_PROXYNAME: 'confluence.local.net'
      CATALINA_CONNECTOR_PROXYPORT: '443'
      CATALINA_CONNECTOR_SCHEME: 'https'
      VIRTUAL_HOST: 'confluence.local.net'
      VIRTUAL_PORT: '8090'
  proxy:
    image: jwilder/nginx-proxy
    ports:
      - 0.0.0.0:80:80
      - 0.0.0.0:443:443
    volumes:
      - ./confluence.local.net.conf:/etc/nginx/vhost.d/confluence.local.net:ro
      - /var/run/docker.sock:/tmp/docker.sock
      - ./certs/:/etc/nginx/certs:ro
    networks:
      - proxy
  database:
    image: blacklabelops/postgres
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=atlassian
      - POSTGRES_DB=confluence
      - POSTGRES_USER=atlassian
      - POSTGRES_ENCODING=UNICODE
      - POSTGRES_COLLATE=C
      - POSTGRES_COLLATE_TYPE=C
    networks:
      - confluence

volumes:
  db_data:
  app_data:

networks:
  confluence:
  proxy:

nginx-proxy takes off on standard ports 80 and 443, I throw a custom config there (if necessary), ssl certificates too

L
letema, 2018-09-27
@letema

And how then to add a dynamic subdomain to the nginx proxy?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question