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

Support for X-Forwarded-Prefix #649

Closed
2 of 6 tasks
twigley opened this issue Apr 27, 2024 · 2 comments
Closed
2 of 6 tasks

Support for X-Forwarded-Prefix #649

twigley opened this issue Apr 27, 2024 · 2 comments
Labels
question Further information is requested

Comments

@twigley
Copy link

twigley commented Apr 27, 2024

Have you read the documentation?

  • Yes, but it does not include related information regarding my question.
  • Yes, but the steps described in the documentation do not work on my machine.
  • Yes, but I am having difficulty understanding it and wants clarification.

You are setting up gotify in

  • Docker
  • Linux native platform
  • Windows native platform

Describe your problem

I'm trying to run gotify from behind Traefik on a subpath rather than a subdomain running with a docker-compose stack as:

  gotify:
    container_name: gotify
    image: gotify/server
    volumes:
      - ${CONFIG_PATH}/gotify:/app/data
    labels:
      - traefik.enable=true
      - traefik.http.routers.gotify.rule=PathPrefix(`/gotify`)
      - traefik.http.services.gotify.loadbalancer.server.port=80
      - traefik.http.routers.gotify.middlewares=gotify
      - traefik.http.middlewares.gotify.stripprefix.prefixes=/gotify

Gotify doesn't appear to respect the header X-Forwarded-Prefix mentioned within https://doc.traefik.io/traefik/middlewares/http/stripprefix/#configuration-options so while the index returns a 200 all static objects return a 404 because they revert to the root path rather than the prefixed path e.g

http://mylocal.domain/gotify - returns a 200 HTTP code

http://mylocal.domain/static/js/main.f445756e.chunk.js - Returns a 404 as it's trying to load the asset from the root path, ignoring X-Forwarded-Prefix.

I'm wondering if there's any way around this without code changes to Gotify. I've looked through a few historical issues but not found anything specific to the use of sub paths that might fix it. I can't find any reference to the header in code so I'm presuming it's not utilised, but I'm not a Go dev by any stretch.

Any errors, logs, or other information that might help us identify your problem

Ex: docker-compose.yml, nginx.conf, android logcat, browser requests, etc.

Example logs from Traefik
```
10.*.*.* - - [27/Apr/2024:21:21:41 +0000] "GET /gotify HTTP/1.1" 200 1458 "-" "-" 95080 "gotify@docker" "http://172.22.0.15:8475" 3ms
10.*.*.* - - [27/Apr/2024:21:21:41 +0000] "GET /static/css/2.0f3898ba.chunk.css HTTP/1.1" 404 1282 "-" "-" 95081 "homepage@docker" "http://172.22.0.14:3000" 6ms
10.*.*.* - - [27/Apr/2024:21:21:41 +0000] "GET /static/js/2.a296d629.chunk.js HTTP/1.1" 404 1282 "-" "-" 95082 "homepage@docker" "http://172.22.0.14:3000" 6ms
10.*.*.* - - [27/Apr/2024:21:21:41 +0000] "GET /static/js/main.f445756e.chunk.js HTTP/1.1" 404 1282 "-" "-" 95083 "homepage@docker" "http://172.22.0.14:3000" 6ms
10.*.*.* - - [27/Apr/2024:21:21:41 +0000] "GET /static/js/2.a296d629.chunk.js HTTP/1.1" 404 1282 "-" "-" 95084 "homepage@docker" "http://172.22.0.14:3000" 2ms
10.*.*.* - - [27/Apr/2024:21:21:41 +0000] "GET /static/js/main.f445756e.chunk.js HTTP/1.1" 404 1282 "-" "-" 95085 "homepage@docker" "http://172.22.0.14:3000" 5ms
10.*.*.* - - [27/Apr/2024:21:21:42 +0000] "GET /static/favicon-196x196.png HTTP/1.1" 404 1282 "-" "-" 95086 "homepage@docker" "http://172.22.0.14:3000" 4ms
10.*.*.* - - [27/Apr/2024:21:21:42 +0000] "GET /static/favicon-32x32.png HTTP/1.1" 404 1282 "-" "-" 95087 "homepage@docker" "http://172.22.0.14:3000" 5ms
```

@twigley twigley added the question Further information is requested label Apr 27, 2024
@jmattheis
Copy link
Member

Add a trailing slash to all prefixes and the url you're accessing: http://mylocal.domain/gotify/

@twigley
Copy link
Author

twigley commented Apr 28, 2024

Add a trailing slash to all prefixes and the url you're accessing: http://mylocal.domain/gotify/

You're a star @jmattheis , it looks like that fixes it within the context of how I'm using it. I'm using homepage so I've just added a trailing slash to the href config for the container and it works now via the sub path.
e.g

  gotify:
    container_name: gotify
    image: gotify/server
    environment:
      - TZ=${TIMEZONE}
    volumes:
      - ${CONFIG_PATH}/gotify:/app/data
    labels:
      - traefik.enable=true
      - traefik.http.routers.gotify.rule=PathPrefix(`/gotify`)
      - traefik.http.services.gotify.loadbalancer.server.port=80
      - traefik.http.routers.gotify.middlewares=gotify
      - traefik.http.middlewares.gotify.stripprefix.prefixes=/gotify
      - homepage.group=Management
      - homepage.name=Gotify
      - homepage.icon=gotify.png
      - homepage.href=/gotify/
      - homepage.description=Notifications

Much appreciated!

@twigley twigley closed this as completed Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

2 participants