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

Hosting homer behind reverse proxy on subpath #578

Open
devedse opened this issue Dec 23, 2022 · 3 comments · May be fixed by #694
Open

Hosting homer behind reverse proxy on subpath #578

devedse opened this issue Dec 23, 2022 · 3 comments · May be fixed by #694

Comments

@devedse
Copy link

devedse commented Dec 23, 2022

Is your feature request related to a problem? Please describe.
I'm trying to use Traefik to host Homer behind a Reverse Proxy. The path I'm trying to use is 192.168.2.207/homer. However all .js includes are being done like this:
image

<link rel="stylesheet" href="./resources/index41a7d45b.css">

Describe the solution you'd like
A way to host homer on a path lower then the root of a webshite.

Describe alternatives you've considered
I tried all kinds of things with Traefik but haven't been able to resolve it. The only other option is trying to do something like homer.blah rather then blah/homer.

Additional context
N/A

@ColdbloodDK
Copy link

ColdbloodDK commented Feb 15, 2023

i think you must use the SUBFOLDER enviroment variable in the docker compose file, i have the same issue and setting the variable like SUBFOLDER=/homer in the docker compose doesn't solve the issue

version: "3.8"
services:
  homer:
    image: b4bz/homer
    container_name: homer
    volumes:
      - ./data:/www/assets
    user: 1000:1000 # default
    environment:
      - INIT_ASSETS=1 # default
      - SUBFOLDER=/homer
      - PORT=80
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.homer.rule=Host(`raspberry`) && Path(`/homer`)"
      - "traefik.http.routers.homer.entrypoints=web"
      - "traefik.http.services.homer.loadbalancer.server.port=80"
      - "traefik.http.routers.homer.middlewares=homer-prefix"
      - "traefik.http.middlewares.homer-prefix.stripprefix.prefixes=/homer"
      - "traefik.http.middlewares.homer-prefix.stripprefix.forceSlash=false"
    networks:
      - traefik
networks:
  traefik:
    external: true

I tried also without the last 3 labels but the problem persists:

- "traefik.http.routers.homer.middlewares=homer-prefix"
- "traefik.http.middlewares.homer-prefix.stripprefix.prefixes=/homer"
- "traefik.http.middlewares.homer-prefix.stripprefix.forceSlash=false"

@mpietruschka
Copy link

mpietruschka commented Feb 21, 2023

I made it work this way....

docker-compose.yml

version: '3'

services:
  reverse-proxy:
    image: traefik:v2.9
    restart: unless-stopped
    labels:
      - "traefik.http.routers.traefik.rule=HostRegexp(`{host:.*}`) && (PathPrefix(`/dashboard`) || PathPrefix(`/api`))"
      - "traefik.http.services.traefik.loadbalancer.server.port=8080"

      - "homer.enable=true"
      - "homer.service=Tools"
      - "homer.name=Traefik WebUI"
      - "homer.subtitle=Reverse proxy dashboard"
      - "homer.url=/dashboard/"
      - "homer.icon=fas fa-traffic-light"
    # Enables the web UI and tells Traefik to listen to docker
    command: --api.insecure=true --providers.docker
    ports:
      # The HTTP port
      - "80:80"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock

  homer:
    image: b4bz/homer:latest
    restart: unless-stopped
    environment:
      - INIT_ASSETS=1 # will be overwritten during first start of discoverer
    labels:
      - "traefik.http.routers.homer-root.rule=HostRegexp(`{host:.*}`) && Path(`/`)"
      - "traefik.http.routers.homer-root.middlewares=homer-root@docker"
      - "traefik.http.middlewares.homer-root.redirectregex.regex=.*"
      - "traefik.http.middlewares.homer-root.redirectregex.replacement=/homer/"

      - "traefik.http.routers.homer.rule=HostRegexp(`{host:.*}`) && PathPrefix(`/homer`)"
      - "traefik.http.routers.homer.middlewares=homer@docker"
      - "traefik.http.middlewares.homer.stripprefix.prefixes=/homer/,/"
      - "traefik.http.services.homer.loadbalancer.server.port=8080"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - homer_assets:/www/assets

  homer-service-discovery:
    image: ghcr.io/calvinbui/homer-service-discovery
    restart: unless-stopped
    environment:
      - HOMER_CONFIG=/homer-assets/config.yml
      - HOMER_BASE_CONFIG=/base.yml
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock
      - homer_assets:/homer-assets
      - ./config/homer/config-base.yml:/base.yml
    depends_on:
      - homer

volumes:
   homer_assets:

@ignatz
Copy link

ignatz commented Aug 30, 2023

I'm sure the proposed solution works, i.e. rewriting content or introducing another reverse proxy to rewrite the paths to reverse the first reverse proxy.

I can offer my own solution #694, however note that unlike the previously proposed solution, while avoiding rewrites, it requires building your own homer docker package to set the vite base url, e.g.:

$ docker build -t homer --build-arg SUBFOLDER=/bar . && docker run --rm -p 8080:8080 -e SUBFOLDER=/bar homer

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 a pull request may close this issue.

4 participants