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

Traefik reverse proxy fails when using base URL #53

Closed
MrLemur opened this issue Feb 11, 2021 · 5 comments
Closed

Traefik reverse proxy fails when using base URL #53

MrLemur opened this issue Feb 11, 2021 · 5 comments

Comments

@MrLemur
Copy link

MrLemur commented Feb 11, 2021

Read the FAQ first!

Describe the bug

Traefik reverse proxy fails if url_base set. Works fine on a subdomain, but will show 404 when on a base URL. The page constantly tries to access css/* etc in a loop when loaded.

image
image

To Reproduce

What to do to reproduce the problem.

Logs

jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 15.106287ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 4.464636ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 4.170007ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 4.261646ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 3.39886ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 4.219146ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 3.291027ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 3.163965ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 3.461112ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 3.266258ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 3.411234ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 3.760947ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 3.579617ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 3.373669ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/remixicon.css) => 404 in 3.285983ms; 
jfa-go_1         | [GIN/DEBUG] 17:44:33: GET(/jfa/css/bundle.css) => 404 in 3.738771ms; 

Configuration

url_base set to /jfa

docker config:

jfa-go:
    image: hrfee/jfa-go:unstable
    restart: always
    user: 1000:1000
    volumes:
      - /opt/docker/jfa-go:/data
      - /opt/docker/jellyfin:/jf
      - /etc/localtime:/etc/localtime:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.jfa-go.rule=Host(`services.${DOMAIN}`) && PathPrefix(`/jfa`)"
      - "traefik.http.routers.jfa-go.tls=true"

Platform/Version

Docker, latest git as of 11/02/2021 17:30 GMT

@hrfee
Copy link
Owner

hrfee commented Feb 11, 2021

The URL has to be rewritten to remove /jfa, with nginx i use
rewrite ^/jfa/(.*) /$1 break;.
Apparently PathPrefixStrip: /jfa would be equivalent in traefik, although i don't know where you would put this.

@MrLemur
Copy link
Author

MrLemur commented Feb 11, 2021

Okay that makes sense. I assume the server in go won't change the directory to serve requests from based on the url_base value?

@hrfee
Copy link
Owner

hrfee commented Feb 11, 2021

No, it doesn't but that probably would have been a better design choice.

@MrLemur
Copy link
Author

MrLemur commented Feb 11, 2021

I now have it working correctly with Traefik if anyone else runs into the issue:

  jfa-go:
    image: hrfee/jfa-go:unstable
    restart: always
    user: 1000:1000
    volumes:
      - /opt/docker/jfa-go:/data
      - /opt/docker/jellyfin:/jf
      - /etc/localtime:/etc/localtime:ro
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.jfa-go.rule=Host(`services.${DOMAIN}`) && PathPrefix(`/jfa`)"
      - "traefik.http.middlewares.jfa-go-strip.stripprefix.prefixes=/jfa"
      - "traefik.http.routers.jfa-go.tls=true"
      - "traefik.http.routers.jfa-go.middlewares=jfa-go-strip@docker"

@hrfee
Copy link
Owner

hrfee commented Feb 11, 2021

I'll stick that on the reverse proxy tab in the wiki, thanks.

@hrfee hrfee closed this as completed Feb 11, 2021
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

No branches or pull requests

2 participants