PiHole running behind nginx-proxy container is through connection refused

Hi people!
My goal is to run NGINX as a proxy and PiHole and another applications behind NGINX proxy. I've pointed all devices in my LAN to use PiHole DNS and I've registered in PiHole DNS solver table two subdomains pihole.localhost and app2.localhost, both pointing to my server LAN IP (192.168.18.187).
Everything works if I directly use the 192.168.18.187 IP, I can reach the PiHole dashboard as it's my default application in NGINX. But if I try pihole.localhost, it throws the error ERR_CONNECTION_REFUSED.

Here are my all docker compose files:
- nginx-proxy docker-compose file:

version: '3.3'
services:
  nginx-proxy:
    image: nginxproxy/nginx-proxy:alpine
    restart: always
    ports:
      - "80:80"
    environment:
      DEFAULT_HOST: pihole.localhost
    volumes:
      - ./current/public:/usr/share/nginx/html
      - ./vhost:/etc/nginx/vhost.d
      - /var/run/docker.sock:/tmp/docker.sock:ro
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
networks:
  default:
    external:
      name: nginx-proxy

- PiHole docker-compose file:

version: "3.3"

# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md

services:
  pihole:
    image: pihole/pihole:latest
    ports:
      - '53:53/tcp'
      - '53:53/udp'
      - "67:67/udp"
      - '8053:80/tcp'
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
      # run `touch ./var-log/pihole.log` first unless you like errors
      # - './var-log/pihole.log:/var/log/pihole/pihole.log'
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    #cap_add:
    #  - NET_ADMIN
    environment:
      FTLCONF_LOCAL_IPV4: 192.168.18.187
      #PROXY_LOCATION: pihole
      PROXY_LOCATION: 192.168.18.187:80
      VIRTUAL_HOST: pihole.localhost
      VIRTUAL_PORT: 80
    networks:
      - nginx-proxy
    #extra_hosts:
      # Resolve to nothing domains (terminate connection)
      #- 'nw2master.bioware.com nwn2.master.gamespy.com:0.0.0.0'
      # LAN hostnames for other docker containers using nginx-proxy Ex:
      #- 'yourDomain.lan:192.168.41.55'
      #- 'pihole pihole.yourDomain.lan:192.168.41.55'
      #- 'ghost ghost.yourDomain.lan:192.168.41.55'
      #- 'wordpress wordpress.yourDomain.lan:192.168.41.55'
      #- 'pihole.localhost:192.168.18.187'
    restart: always

networks:
  nginx-proxy:
    external: true

And I've checked if the pi-hole DNS solving was correct, and it's working properly:

nslookup pihole.localhost
Server:		192.168.18.187
Address:	192.168.18.187#53

Name:	pihole.localhost
Address: 192.168.18.187

Could anyone help me? Thanks in advance :pray:

I was following this tutorial:

What is the exact URL you are trying to access?

1 Like

This one:
http://pihole.localhost

But I've tried this another one as well:
http://app2.localhost

None of them has worked.
My apologies about the delay in responding. I wasn't notified about your reply.

Are you able to access the web interface directly, without the reverse proxy?

In your case, the URL should be http://192.168.18.187:8053/admin.

1 Like

Yes, I'm able to access the web interface directly as well using the 8053 port.