Docker Community Forums

Share and learn in the Docker community.

Docker Nginx-proxy Durpal


(Runa68) #1

Hello i have a problem with my docker-compose

I use nginx-proxy and nginx-proxy-compagnion to have multiple sites on the same vps and for the automatic ssl.

After a lot of testing, I installed nginx as a web server to run Drupal.

The problem nothing works …
Neither the database nor the Drupal files etc …

I can not find where the problem comes from !!
I’m on the brink of removing all this and make my server by hand!

Thank you for your help !

version: ‘2’

services:
    nginx-proxy:
        restart: always
        image: jwilder/nginx-proxy
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - /srv/docker/nginx/certs:/etc/nginx/certs:ro
            - /etc/nginx/vhost.d
            - /usr/share/nginx/html
            - /var/run/docker.sock:/tmp/docker.sock:ro

    nginx-proxy-companion:
        image: jrcs/letsencrypt-nginx-proxy-companion
        volumes:
            - /srv/docker/nginx/certs:/etc/nginx/certs:rw
            - /var/run/docker.sock:/var/run/docker.sock
        volumes_from:
            - nginx-proxy

    web:
        image: nginx
        volumes:
            - /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
            - /var/www/html
        links: 
            - nginx-proxy
            - php
        ports:
            - "8080:8080"
    
    php:
        image: php:7-fpm
        ports:
            - "9000:9000"

    drupal:
        image: drupal:8.4-fpm
        volumes:
            - /var/www/html/modules
            - /var/www/html/profiles
            - /var/www/html/themes
            - /var/www/html/sites/default/files
        restart: always
        links:
            - mysql
            - web
        environment:
            - VIRTUAL_HOST=les-decouvertes-de-runa.fr
            - LETSENCRYPT_HOST=les-decouvertes-de-runa.fr
            - LETSENCRYPT_EMAIL=les-decouvertes-de-runa.fr

    mysql:
        image: mysql
        ports:
            - "3306:3306"
        environment:
            - MYSQL_PASSWORD=mdp
            - MYSQL_USER=user
            - MYSQL_DATABASE=database
            - MYSQL_ROOT_PASSWORD=mdproot
        restart: always
        volumes:
            - /opt/mysql_data:/var/lib/mysql

(Arikin) #2

You have the VIRTUAL_HOST environment set for drupal but you need to expose the port(s) for drupal.

services:
  drupal:
    expose:
      - 80
      - 443

Then at the bottom add a network all can use:

networks:
  default:
    external:
      name: nginx-proxy

But that means you setup the external network from the command line.

$ docker network create nginx-proxy

Taken from experience and this website: Multiple websites