Score:0

How to properly configure Nginx proxy in docker-compose.yml

ru flag

I use Ubuntu with docker and I need to set up my local server with Nextcloud and Openproject. For connection form internet(outside) I use dynamic DNS (ddns.net service). When I use this connection in localhost it works. But nothing works from outside. But my nginx is reachable because I get 503 error. My ddns adress is mydomain.ddns.net

Desired redirection is:

openproject.mydomain.ddns.net ==> openproject container
nextcloud.mydomain.ddns.net ==> nextcloud container

I am not able to properly configure nginx proxy container to redirect to container. I have this docker-compose.yml file:

version: '3' 

services:

  proxy:
    image: jwilder/nginx-proxy:alpine
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    container_name: nextcloud-proxy
    networks:
      - nextcloud_network
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./proxy/conf.d:/etc/nginx/conf.d:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - ./proxy/certs:/etc/nginx/certs:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: unless-stopped
  
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nextcloud-letsencrypt
    depends_on:
      - proxy
    networks:
      - nextcloud_network
    volumes:
      - ./proxy/certs:/etc/nginx/certs:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: unless-stopped

  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed
    container_name: nextcloud-mariadb
    networks:
      - nextcloud_network
    volumes:
      - db:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_PASSWORD=pass
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped
  
  app:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      - nextcloud_network
    depends_on:
      - letsencrypt
      - proxy
      - db
    volumes:
      - nextcloud:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - ./app/data:/var/www/html/data
      - ./app/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - VIRTUAL_HOST=nextcloud.mydomain.ddns.net
      - LETSENCRYPT_HOST=nextcloud.mydomain.ddns.net
      - [email protected]
    restart: unless-stopped
    
  app2:
    image: openproject/community:11
    container_name: openproject-app
    networks:
      - nextcloud_network
    depends_on:
      - letsencrypt
      - proxy
      - db2
    volumes:
      - openproject:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - ./app/data:/var/www/html/data
      - ./app/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - SECRET_KEY_BASE=secret
      - VIRTUAL_HOST=openproject.mydomain.ddns.net
      - LETSENCRYPT_HOST=openproject.mydomain.ddns.net
      - [email protected]
    restart: unless-stopped

  db2:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed
    container_name: openproject-mariadb
    networks:
      - nextcloud_network
    volumes:
      - db2:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=pass
      - MYSQL_PASSWORD=pass
      - MYSQL_DATABASE=openproject
      - MYSQL_USER=openproject
    restart: unless-stopped

volumes:
  openproject:
  nextcloud:
  db:
  db2:


networks:
  nextcloud_network:

Thanks, for help :)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.