hrfee / jfa-go

a bit-of-everything user managament app for Jellyfin
https://jfa-go.com
Other
804 stars 57 forks source link

Reverse Proxy: URL Base being ignored for certain paths #42

Closed owdevel closed 3 years ago

owdevel commented 3 years ago

Read the FAQ first!

Describe the bug

Web paths seem to ignore url_base value when looking for banner.svg, bundle.css, remixicon.css and when navigating between invites, accounts and settings. This affects link generation as the link will omit the url_base value if you have switched tabs and therefore fail.

E.g. Reverse proxy to http://test.com/accounts. After navigating to the other pages (Accounts/Settings) the /accounts is dropped (http://test.com/settings). Navigating back to the invites page will result in the invite url being http:/test.com/invite/xxx.... which will fail to parse.

The invite links do generate properly however if the accounts/settings pages are not accessed thereby not dropping the url_base.

To Reproduce

  1. Startup jfa-admin with the latest docker image (0.2.5) or latest commit (46fe3a7)
  2. Setup url_base to be /accounts
  3. Setup reverse-proxy to link to /accounts (tested with Caddy2 and nginx using the supplied config in the wiki)
  4. Load the page (e.g. http(s)://domain.com/accounts/)

Whilst the interface looks fine and is mostly functional, there are errors in the console for resources.

  1. Navigate to Accounts or Settings page URL will change to omit the url_base resulting in /accounts and /settings rather than /url_base/accounts, /url_base/settings

  2. Navigate back to Invites page, url_base will not be visible

  3. Generate invite link, link does not include url_base

Logs Docker Image Logs - Nothing special. All HTTP 200 responses

Chrome Console Logs - Initial Connect

GET http://host.com/css/bundle.css net::ERR_ABORTED 404 (Not Found)
GET http://host.com/css/remixicon.css net:ERR_ABORTED 404 (Not Found)
GET http://192.168.1.200:8080/banner.svg 404 (Not Found)
GET http://192.168.1.200:8080/accounts/token/refresh 400 (Bad Request)

Configuration config.ini

url_base = /accounts

nginx config

http {
  server {
    listen 80;
    location ~ ^/accounts/(.*)$ {
      rewrite ^/accounts/(.*) /$1 break;
      proxy_hide_header Content-Security-Policy;
      add_header Content-Security-Policy "";
      proxy_pass http://localhost:8056;
      http2_push_preload on;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Protocol $scheme;
      proxy_set_header X-Forwarded-Host $http_host;
      proxy_buffering off;
    }
  }
}

Caddy2 Caddyfile

host.com {
  route /accounts* {
    uri strip_prefix /accounts
    reverse_proxy localhost:8056
  }
}

Platform/Version Docker Containers running on Host Debian distributions. Tested with docker:latest and docker:unstable with the same results. hrfee/jfa-go:latest (0.2.5, fdc97b4) hrfee/jfa-go:unstable (46fe3a7)

Accessed through Chrome on Linux version 88.0.4324.146

hrfee commented 3 years ago

Fixed in b037b0815263ab3be9b1bc967846b24b079c55b0 which should be on dockerhub unstable soon.

hrfee commented 3 years ago

Only read the first part of the issue, sorry. That commit only fixes the banner.svg thing.

hrfee commented 3 years ago

Ok, the other two issues should be fixed in 2c8be42 and 6691ae27f40cfee58ed57347ff3a69ad194ec195.