homer icon indicating copy to clipboard operation
homer copied to clipboard

pihole stats only available in dashboard if web ui isn't password protected

Open justin1703 opened this issue 1 year ago • 6 comments

Describe the bug I can only see the pihole stats when I have no password set. If I do so and add the api key into the config.yml the dashboard isnt showing anything.

Expected behavior I should be able to see the pihole stats no password: grafik

added api keys after changing password: grafik grafik


justin1703 avatar Sep 16 '23 00:09 justin1703

Note: I just updated both pihole instances

justin1703 avatar Sep 16 '23 00:09 justin1703

I have the same issue.

homer compose.yaml

services:
  homer:
    image: b4bz/homer:latest
    container_name: ${CONTAINER}
    hostname: ${CONTAINER}.${HOSTNAME}
    dns: ${DNS}
    ports:
      - 8888:8888
    environment:
      - PORT=${PORT}
    volumes:
      - ${DIRECTORY_ASSETS}:/www/assets
    restart: unless-stopped
    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.homer-rtr.rule=Host(`homer.example.com`)"
      - "traefik.http.routers.homer-rtr.entrypoints=web, websecure"
      - "traefik.http.routers.homer-rtr.middlewares=homer-mdl"
      - "traefik.http.routers.homer-rtr.service=homer-srv"
      - "traefik.http.routers.homer-rtr.tls=true"
      - "traefik.http.middlewares.homer-mdl.headers.customResponseHeaders.Access-Control-Allow-Origin=https://example.com"
      - "traefik.http.middlewares.homer-mdl.headers.accesscontrolallowmethods=GET,OPTIONS,PUT"
      - "traefik.http.middlewares.homer-mdl.headers.accessControlAllowOriginListRegex=https://(.*?).example.com"
      - "traefik.http.services.homer-srv.loadbalancer.server.port=8888"
      - "traefik.http.services.homer-srv.loadbalancer.server.scheme=http"
    networks:
      my-net:
        ipv4_address: ${NETWORK_IPV4_ADDRESS}
networks:
  my-net:
    name: ${NETWORK_NAME}
    external: true
homer config.yml extract

services:
  - name: "Edge"
    icon: "fas fa-shield-halved"
    items:
      - name: "Traefik"
        logo: "assets/tools/traefik.png"
        subtitle: "Reverse Proxy"
        tag: "edge"
        url: "https://traefik.example.com"
        target: "_blank"
      - name: "Pi-hole 1"
        logo: "assets/tools/pihole.png"
        tag: "edge"
        url: "https://pihole-1.example.com/admin"
        target: "_blank"
        type: "PiHole"
        apikey: "[big-long-api]"
      - name: "Pi-hole 2"
        logo: "assets/tools/pihole.png"
        tag: "edge"
        url: "https://pihole-2.example.com/admin"
        target: "_blank"
        type: "PiHole"
        apikey: "[big-long-api]"

Screenshot showing no results on pihole containers but responses on some services: image

Screenshot showing console with no CORS errors but unexpected issues when parsing the json file returned by pihole: image

Please let me know if I can provide any other information.

instantdreams avatar Sep 26 '23 05:09 instantdreams

Also experiencing the same thing as others.

almulder avatar Sep 27 '23 21:09 almulder

Same.

philfry9 avatar Oct 27 '23 04:10 philfry9

I have resolved this issue.

For my pi-hole docker instances, I set the CORS hosts as follows:

CORS_HOSTS=example.com,homer.example.com,homeassistant.example.com

For my traefik docker instance, I created a file called "cors.yaml" with the following:

http:
  middlewares:
    example-com-cors:
      headers:
        accessControlAllowHeaders: "*"
        accessControlAllowMethods:
          - GET
          - OPTIONS
          - PUT
        accessControlAllowOriginListRegex:
          - https://(.*)?example\.com(.*)
        accessControlMaxAge: 100
        addVaryHeader: true

My homer compose.yaml file - and any other containers that need to enable CORS - has the following labels added:

    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.homer-rtr.rule=Host(`${HOSTNAME1}.${DOMAINNAME}`)"
      - "traefik.http.routers.homer-rtr.entrypoints=websecure"
      - "traefik.http.routers.homer-rtr.middlewares=example-com-cors@file"
      - "traefik.http.routers.homer-rtr.service=homer-srv"
      - "traefik.http.routers.homer-rtr.tls=true"
      - "traefik.http.services.homer-srv.loadbalancer.server.port=${WEBPORT1}"
      - "traefik.http.services.homer-srv.loadbalancer.server.scheme=http"

That has resolved the issue with CORS and Homer for me, for any target that requires CORS.

instantdreams avatar Mar 18 '24 14:03 instantdreams

I have resolved this issue.

For my pi-hole docker instances, I set the CORS hosts as follows:

CORS_HOSTS=example.com,homer.example.com,homeassistant.example.com

For my traefik docker instance, I created a file called "cors.yaml" with the following:

http:
  middlewares:
    example-com-cors:
      headers:
        accessControlAllowHeaders: "*"
        accessControlAllowMethods:
          - GET
          - OPTIONS
          - PUT
        accessControlAllowOriginListRegex:
          - https://(.*)?example\.com(.*)
        accessControlMaxAge: 100
        addVaryHeader: true

My homer compose.yaml file - and any other containers that need to enable CORS - has the following labels added:

    labels:
      # Traefik
      - "traefik.enable=true"
      - "traefik.http.routers.homer-rtr.rule=Host(`${HOSTNAME1}.${DOMAINNAME}`)"
      - "traefik.http.routers.homer-rtr.entrypoints=websecure"
      - "traefik.http.routers.homer-rtr.middlewares=example-com-cors@file"
      - "traefik.http.routers.homer-rtr.service=homer-srv"
      - "traefik.http.routers.homer-rtr.tls=true"
      - "traefik.http.services.homer-srv.loadbalancer.server.port=${WEBPORT1}"
      - "traefik.http.services.homer-srv.loadbalancer.server.scheme=http"

That has resolved the issue with CORS and Homer for me, for any target that requires CORS.

Thank you for that diagnosis. For those that have the same issue and are using Nginx Proxy Manager, it seems to be sufficient to add the CORS_HOSTS environment variable for the Pi Hole Docker container. NPM did not require any additional configuration for me.

lafe avatar Apr 04 '24 14:04 lafe