question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nginx with pihole, nextcloud, openhab - only error 503

See original GitHub issue

i like to run pihole, openhab and nextcloud with mariadb with ssl encryption on my homeserver but i dont get it to run probably.

i know there are some 503 error issues already but nothing helful for me. i hope someone can help me and tell me what i am doing wrong

i always get only an 503 error, i tried it with and without lets encrypt and with https redirection and without

here is my compose file

version: '3.7' 

services:

  nginx:
    image: jwilder/nginx-proxy:alpine
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    container_name: nginx
    ports:
      - 80:80
      - 443:443
    networks:
      - nginx_network
    volumes:
      - /home/server/docker/nginx/conf.d:/etc/nginx/conf.d
      - /home/server/docker/nginx/vhost.d:/etc/nginx/vhost.d
      - /home/server/docker/nginx/html:/usr/share/nginx/html
      - /home/server/docker/nginx/certs:/etc/nginx/certs:ro
      - /home/server/docker/nginx/htpasswd:/etc/nginx/htpasswd
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro

    environment:
      - DEFAULT_HOST=pihole.domain1.de
      - HTTPS_METHOD=noredirect

    restart: always
  
  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt
    depends_on:
      - nginx
    networks:
      - nginx_network

    volumes:
      - /home/server/docker/nginx/certs:/etc/nginx/certs:rw
      - /home/server/docker/nginx/vhost.d:/etc/nginx/vhost.d:rw
      - /home/server/docker/nginx/html:/usr/share/nginx/html:rw
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: always

  mariadb:
    image: mariadb
    container_name: mariadb
    restart: always
    networks:
      - nginx_network
    volumes:
      - /home/server/docker/mariadb/mysql:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=root_password
      - MYSQL_PASSWORD=mysql_password
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: always
    depends_on:
      - letsencrypt
      - nginx
      - mariadb
    networks:
      - nginx_network
    volumes:
      - /home/server/docker/nextcloud/html:/var/www/html
      - /home/server/docker/nextcloud/config:/var/www/html/config
      - /home/server/docker/nextcloud/custom_apps:/var/www/html/custom_apps
      - /media/Daten/Nextcloud:/var/www/html/data
      - /home/server/docker/nextcloud/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - VIRTUAL_HOST=mycloud.domain1.de,mycloud.domain2.de
      - VIRTUAL_PROTO=https
      - VIRTUAL_PORT=443
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=mycloud.domain1.de,mycloud.domain2.de
      - LETSENCRYPT_EMAIL=my@email.address


  pihole:
    image: pihole/pihole:latest
    container_name: pihole
    restart: always
    depends_on:
      - letsencrypt
      - nginx
    networks:
      - nginx_network
    volumes:
      - /home/server/docker/pihole/log/pihole.log:/var/log/pihole.log
      - /home/server/docker/pihole:/etc/pihole
      - /home/server/docker/pihole/dnsmasq.d:/etc/dnsmasq.d
  #net: host
    cap_add:
      - NET_ADMIN
    environment:
      - TZ=Europe/Berlin
      - WEBPASSWORD=pihole
      - DNS1=46.182.19.48
      - DNS2=194.150.168.168
      - DNSMASQ_LISTENING=all
      - ServerIP=192.168.13.5
      - PROXY_LOCATION=pihole
      - VIRTUAL_HOST=pihole.domain1.de,pihole.domain2.de
      - VIRTUAL_PROTO=https
      - VIRTUAL_PORT=443
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=pihole.domain1.de,pihole.domain2.de
      - LETSENCRYPT_EMAIL=my@email.address



  openhab:
    image: openhab/openhab:2.3.0-amd64-debian
    container_name: openhab
    restart: always
    depends_on:
      - letsencrypt
      - nginx
    networks:
      - nginx_network
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /home/server/docker/openhab/addons:/openhab/addons
      - /home/server/docker/openhab/conf:/openhab/conf
      - /home/server/docker/openhab/userdata:/openhab/userdata
    environment:
      #OPENHAB_HTTP_PORT=8080
      #OPENHAB_HTTPS_PORT=8443
      - USER_ID=9001
      - GROUP_ID=9001
      - VIRTUAL_HOST=openhab.domain1.de,,openhab2.domain2.de
      - VIRTUAL_PROTO=https
      - VIRTUAL_PORT=443
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=openhab.domain1.de,,openhab2.domain2.de
      - LETSENCRYPT_EMAIL=my@email.address



networks:
  nginx_network:
    driver: bridge

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
bkraulcommented, May 5, 2019

@rlue:

Can you elaborate on this? Do you just have an addn-hosts=/etc/dnsmasq.hosts line in 02-custom.conf, and then specify your docker host IPs there? Or can you specify host-IP mappings directly in the dnsmasq conf file somehow?

No, I put the file 02-custom.conf file inside the dnsmasq.d folder. Pihole automatically parses it in, which is why I set the file name to 02-..., that it will not clash with the main config file.

The hostnames are mapped to LAN IPs, for example:

# 10.10.10.127 - docker.belmankraul.com
address=/rocketchat.belmankraul.com/10.10.10.127
address=/docker.belmankraul.com/10.10.10.127
address=/git.belmankraul.com/10.10.10.127
address=/suitecrm.belmankraul.com/10.10.10.127
address=/nextcloud.belmankraul.com/10.10.10.127

They are are resolving to the same LAN IP, because of the nginx-proxy setup.

What is the purpose of the PROXY_LOCATION=pihole environment variable? I can’t find a reference to it anywhere in the README

As I understand it, PROXY_LOCATION is used when pihole is run behind a jwilder/nginx-proxy setup, but I am not certain. All I know is that it does not hurt being there.

0reactions
rluecommented, May 6, 2019

Brilliant, thanks! I’ve fiddled with so many things, I can’t even tell what’s necesssary and what’s not anymore, but I think I got away with:

  1. no 02-custom.conf file at all,
  2. setting the ServerIP environment variable on the pihole container to the pihole machine’s LAN IP, and
  3. making sure the VIRTUAL_HOST environment variable on the pihole container is not pi.hole.

With this, it looks like all the dockerized web services behind my nginx proxy are accessible both on the local network and on the Internet. I suspect that if these were LAN-only addresses, I’d need either the 02-custom.conf file or the extra_hosts docker compose option. (Honestly not sure if one can stand in for the other; I just see that you use the former, and this sample docker compose file uses the latter.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

nginx with pihole, nextcloud, openhab - only error 503 #1169
For reference, I am using my pihole instance to define static DNS entries for all the servers I run in my docker environment...
Read more >
HTTP 503 Error - installation - Nextcloud community
Hello, I have a problem when I try to install Nextcloud. I use NGINX, with the Owncloud vhost. I changed directories to match...
Read more >
Config Openhabian + Pihole + Nginx all on one device
I know its not recommended to install multiple things on on device, but hardware is much faster nowadays. So I´ve setup and configured ......
Read more >
503 Error on Ingress with pi-hole [HELP] : r/kubernetes - Reddit
You probably have the IP wrong. The guide is confusing but you need to get the IP of the node that you're NGINX...
Read more >
Index of Unsupported Software - Gentoo Forums
Page:1 · "Error installing application with Lutris" Page:1 · "Dantrell's GNOME Without Systemd ... "Install mod_pagespeed under nginx on gentoo" Page:1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found