Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow path prefix multiplexing the dashboard and API #3269

Merged
merged 5 commits into from
Mar 22, 2025
Merged

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Mar 2, 2025

What does this implement/fix?

See pi-hole/FTL#2319 for further details. This PR mostly consists of search-and-replace to remove hard-coded absolute paths for the login page as well as adding the ability to send API requests to anywhere else than the fixes /api path.

Note

You will need the related FTL branch new/web_prefix for this to work as expected.


Related issue or feature (if applicable): Fixes pi-hole/FTL#2298

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

Sorry, something went wrong.

…#2319 for further details

Signed-off-by: DL6ER <dl6er@dl6er.de>
…ead of calling pihole.webhome() multiple times

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER mentioned this pull request Mar 9, 2025
1 task
Copy link
Contributor

github-actions bot commented Mar 9, 2025

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@DL6ER DL6ER requested a review from a team March 9, 2025 19:14
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER marked this pull request as ready for review March 9, 2025 19:16
Copy link
Contributor

github-actions bot commented Mar 9, 2025

Conflicts have been resolved.

@XhmikosR
Copy link
Contributor

XhmikosR commented Mar 9, 2025

My only comment in those vars, unsure how to quickly do it better. Have you tried let and disabling any offending ESLint rule for those lines?

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved.

Signed-off-by: DL6ER <dl6er@dl6er.de>
@dschaper
Copy link
Member

This is what I'm testing with, and access looks good.

Compose file, running Pi-hole outside of the docker stack on the host:

root@pht:/etc/pihole# cat traefik-pihole-issue-docker.yml 
services:
  traefik:
    image: "traefik:v3.3.3"
    container_name: "traefik"
    command:
      - "--accessLog=true"
      - "--tracing=true"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.file.directory=/etc/traefik/"
      - "--entryPoints.web.address=:80"
      - "--entryPoints.dnstcp.address=:53"
      - "--entryPoints.dnsudp.address=:53/udp"
    ports:
      - "53:53"
      - "53:53/udp"
      - "80:80"
      - "8080:8080"
    restart: unless-stopped
    volumes:
      - "/etc/timezone:/etc/timezone:ro"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./etc-traefik:/etc/traefik:ro"

  whoami:
    image: "traefik/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=PathPrefix(`/whoami`)"
      - "traefik.http.routers.whoami.entrypoints=web"
      - "traefik.http.routers.whoami.middlewares=stripwhoami"
      - "traefik.http.middlewares.stripwhoami.stripprefix.prefixes=/whoami/"

Dynamic configuration, file provider, for the host installed Pi-hole.

root@pht:/etc/pihole/etc-traefik# cat dynamic.yaml 
http:
  routers:
    pihole:
      entryPoints:
        - web
      rule: "PathPrefix(`/pihole`)"
      middlewares:
        - piholehttp
      service: piholehttp
  middlewares:
    piholehttp:
      stripPrefix:
        prefixes:
          - "/pihole"
  services:
    piholehttp:
      loadBalancer:
        servers:
          - url: "http://192.168.1.190:8081"

pihole.toml

# Prefix where the web interface is served
# This is useful when you are using a reverse proxy serving the web interface, e.g.,
# at http://<ip>/pihole/admin/ instead of http://<ip>/admin/. In this example, the
# prefix would be "/pihole". Note that the prefix has to be stripped away by the
# reverse proxy, e.g., for traefik:
# - traefik.http.routers.pihole.rule=PathPrefix('/pihole)
# - traefik.http.middlewares.piholehttp.stripprefix.prefixes=/pihole
# The prefix should start with a slash. If you don't use a prefix, leave this field
# empty. Setting this field to an incorrect value may result in the web interface not
# being accessible.
Don't use this setting if you are not using a reverse proxy!

Possible values are:
valid URL prefix or empty
prefix = "/pihole" ### CHANGED, default =

Image

Image

@DL6ER DL6ER merged commit 877d5f8 into development Mar 22, 2025
11 checks passed
@DL6ER DL6ER deleted the new/web_prefix branch March 22, 2025 19:46
@PromoFaux PromoFaux mentioned this pull request Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants