PiHole with docker/traefik tutorial | PlexGuide.com

PiHole with docker/traefik tutorial

  • Stop using Chrome! Download the Brave Browser via >>> [Brave.com]
    It's a forked version of Chrome with native ad-blockers and Google's spyware stripped out! Download for Mac, Windows, Android, and Linux!
Welcome to the PlexGuide.com
Serving the Community since 2016!
Register Now

CyborgPirate

Experienced
Original poster
Aug 22, 2018
96
34
Hey guys,
I came across this tutorial for getting pi hole working with a traefik and docker and thought others might be interested.
https://www.smarthomebeginner.com/run-pihole-in-docker-on-ubuntu-with-reverse-proxy/

I haven't tried it out yet but it looks pretty comprehensive.

I was thinking of trying to get it working with wireguard which I have already running on my PlexGuide server for a remote encrypted VPN with an adblocker built in.

Any thoughts?
 
  • Like
Reactions: 1 user

crustyakorn

Experienced
Aug 30, 2018
59
23
Would be nice to set up this app on PGBlitz.

Can it be done in a way that Docker exposes this container to get its' own IP address of the subnet/modem/router? This way i could point my devices to use the DNS Server IP from the "dedicated" container.
 

Admin9705

Administrator
Project Manager
Donor
Jan 17, 2018
5,151
2,120
an issue u have to overcome is docker uses port 80 and 443; pihole i believe needs one or both those ports.
 

Sejrup

Experienced
Jan 11, 2019
75
25
I made this work using the guide from the webpage. I made it work using Docker Compose though. Will try to take a look at converting the docker-compose.yml file to ansible so that in can be uploaded to the community repo.

Let me know if you have any questions. I know nothing about Linux, but am quite stubborn ?
 

Admin9705

Administrator
Project Manager
Donor
Jan 17, 2018
5,151
2,120
I made this work using the guide from the webpage. I made it work using Docker Compose though. Will try to take a look at converting the docker-compose.yml file to ansible so that in can be uploaded to the community repo.

Let me know if you have any questions. I know nothing about Linux, but am quite stubborn ?
Ya but treafik will be the problem. If you figure it, that would be awesome
 
  • Like
Reactions: 1 user

captngimpy

Experienced+
Staff
Mar 14, 2018
112
32
I knew pihole had been talked about earlier and I was running through my monthly expenses and I have one vps I use for pihol mostly(cause it was cheap and I'm a sucker for a deal) but anything I can cut out (spring cleaning is coming) and run off my dedicated server through docker would be great.
 
  • Like
Reactions: 1 user

Sejrup

Experienced
Jan 11, 2019
75
25
Ya but treafik will be the problem. If you figure it, that would be awesome
Yes, it appears to be working with Traefik. I have the certs on the domain pihole.example.com and can route all traffic through the DNS (y) Will do a bit more testing today if I have time.
 
  • Like
Reactions: 3 users

Admin9705

Administrator
Project Manager
Donor
Jan 17, 2018
5,151
2,120
Yes, it appears to be working with Traefik. I have the certs on the domain pihole.example.com and can route all traffic through the DNS (y) Will do a bit more testing today if I have time.
awesome great to know
 

PonsterManda

Experienced
Staff
Apr 26, 2019
71
43
Yes, it appears to be working with Traefik. I have the certs on the domain pihole.example.com and can route all traffic through the DNS (y) Will do a bit more testing today if I have time.
You mean making use of an alternative DNS server for your DNS queries. Pihole isnt routing all traffic ;)
 

Sejrup

Experienced
Jan 11, 2019
75
25
In case anyone wants to give it a try, I have posted my yaml code below. Just copy/paste contents to pihole.yml and upload to the /opt/mycontainers folder. Then you can install it via PG Box and Community.

I did perform the initial steps outlined in the guide that OP linked to. Not entirely sure if needed though. As far as I can tell network-manager is not installed per default in 18.0.4 so I installed that manually. There was a lot of back and forth for me initially so I kind of lost track a bit of what is needed in order to make it work. I think I might have added a nameserver in /etc/resolv.conf because I couldn't resolve any addresses after disabling and stopping Ubuntu’s DNS resolver.

A few things should be modified according to your needs

ServerIP: '192.168.1.10'
WEBPASSWORD: 'PIHOLEWEBPASSWORD'
DNS2: '1.1.1.1' - In case you want to use a different DNS server than Cloudflare

I havent quite figured out how to push it to the Github repo yet. Maybe also best to wait until someone besides me tries it out :)

YAML:
#!/bin/bash
#
# Title:      PGBlitz (Reference Title File)
# Author(s):  Admin9705
# URL:        https://pgblitz.com - http://github.pgblitz.com
# GNU:        General Public License v3.0
################################################################################
---
- hosts: localhost
  gather_facts: false
  tasks:
    # FACTS #######################################################################
    - name: 'Set Known Facts'
      set_fact:
        pgrole: 'pihole'
        intport: '53/tcp'
        extport: '53'
        intport2: '53/udp'
        extport2: '53'
        intport3: '80'
        extport3: '8182'
        intport4: '443'
        extport4: '8183'
        image: 'pihole/pihole:latest'

    # CORE (MANDATORY) ############################################################
    - name: 'Including cron job'
      include_tasks: '/opt/coreapps/apps/_core.yml'

    # LABELS ######################################################################
    - name: 'Adding Traefik'
      set_fact:
        pg_labels:
           traefik.enable: 'true'
           traefik.backend: '{{pgrole}}'
           traefik.frontend.rule: 'HostRegexp:{{pgrole}}.{{domain.stdout}},{{tldset}},{catchall:.*}'
           traefik.frontend.priority: '1'
           traefik.frontend.headers.SSLRedirect: 'true'
           traefik.frontend.headers.STSSeconds: '315360000'
           traefik.frontend.headers.browserXSSFilter: 'true'
           traefik.frontend.headers.contentTypeNosniff: 'true'
           traefik.frontend.headers.forceSTSHeader: 'true'
           traefik.frontend.headers.SSLHost: '{{domain.stdout}}'
           traefik.frontend.headers.STSIncludeSubdomains: 'true'
           traefik.frontend.headers.STSPreload: 'true'
           traefik.frontend.headers.frameDeny: 'true'
           traefik.frontend.auth.forward.address: '{{gauth}}'
           traefik.port: '{{intport3}}'

    - name: 'Setting PG Volumes'
      set_fact:
        pg_volumes:
          - '/opt/appdata/pihole/{{pgrole}}:/etc/pihole'
          - '/opt/appdata/{{pgrole}}/dnsmasq.d:/etc/dnsmasq.d'
          - '/etc/localtime:/etc/localtime:ro'

    - name: 'Setting PG ENV'
      set_fact:
        pg_env:
          PUID: '1000'
          PGID: '1000'
          ServerIP: '192.168.1.10'
          PROXY_LOCATION: '{{pgrole}}'
          VIRTUAL_HOST: '{{pgrole}}.{{domain.stdout}}'
          VIRTUAL_PORT: '{{intport3}}'
          TZ: '${TZ}'
          WEBPASSWORD: 'PIHOLEWEBPASSWORD'
          DNS1: '127.0.0.1'
          DNS2: '1.1.1.1'

    # MAIN DEPLOYMENT #############################################################
    - name: 'Deploying {{pgrole}}'
      docker_container:
        name: '{{pgrole}}'
        image: '{{image}}'
        pull: yes
        published_ports:
          - '{{ports.stdout}}{{extport}}:{{intport}}'
          - '{{ports.stdout}}{{extport2}}:{{intport2}}'
          - '{{ports.stdout}}{{extport3}}:{{intport3}}'
          - '{{ports.stdout}}{{extport4}}:{{intport4}}'
        volumes: '{{pg_volumes}}'
        env: '{{pg_env}}'
        restart_policy: unless-stopped
        networks:
          - name: plexguide
            aliases:
              - '{{pgrole}}'
        state: started
        labels: '{{pg_labels}}'
 
  • Like
  • Love
  • Roast
Reactions: 3 users

shmookles

Active
Dec 30, 2018
33
2
Any update on this? Would love for the to become a community official app. pi-hole is super useful.
 
  • Like
Reactions: 1 user

Sejrup

Experienced
Jan 11, 2019
75
25
Check out the following post in the "What Docker would you like to have created" for a working .yml file for pi-hole.
 

evlo

Active
Feb 13, 2020
32
6
What to do if port 53 (dns) is in use?
Is it necessary to fill ServerIP? And if so - should this by DNS server ip - so in case it is on interent should i fill internet ip or is to for the local ip?


Docker Pi-Hole v4.2.2
  • ServerIP no longer a required enviroment variable unless you run network 'host' mode! Feel free to remove it unless you need it to customize lighttpd
Debian 9.12
Code:
sudo lsof -i :53
systemctl stop bind9.service

after that I can see pihole running on 53, but i'm not able to access https://pihole.*


well.... don't forget to add CNAME in your DNS :D


I have verified that
Code:
ServerIP
can be removed from yml file
Post automatically merged:

Unfortunately even though I get web interface working and in log in portanier all seems good, i'm not able to resolve anything, i tried setting ports in port guard to open, but that did not help, maybe debian has some firewall for dns or simething?

I did set up Listen on all interfaces, permit all origins



I have verified that pihole runs by trying nslookup locally on the server. Maybe it is generally forbidden to run DNS server on the internet os providers block port 53?

Post automatically merged:

Also note - if you are using cloudflare proxy, pining you server name will give you cloudflare ip, use
Code:
dig +short myip.opendns.com @resolver1.opendns.com
or look for ip in provider panel
Post automatically merged:

Still I have this issue with records by nslookup returned by opendns and not server i specify, I don't understand :(


Post automatically merged:


Post automatically merged:

Thinking about it, maybe I should have filled that ServerIP when setting up docker container ...
Post automatically merged:

 
Last edited:

sickoo0

Active
Mar 4, 2018
38
3
:(

1605735813944.png
Post automatically merged:

Okay i have setup pi hole on my dedicated server, how can i access it through my home router ?
Post automatically merged:

What am I doing wrong it's not working.https://www.indeed.com/community/interview-tips/what-am-i-doing-wrong-i-can-t-get-a-job/td-p/1121859
1606558611426.png
Post automatically merged:

:(

1605735813944.png
Post automatically merged:

Okay i have setup pi hole on my dedicated server, how can i access it through my home router ?
Post automatically merged:

What am I doing wrong it's not working.
1606558611426.png
 
Last edited:

Recommend NewsGroups

      Up To a 58% Discount!

Trending