linuxserver / docker-calibre

GNU General Public License v3.0
338 stars 62 forks source link

[BUG] Calibre in a SubFolder w/ Reverse Proxy not working #129

Closed feldorn closed 1 year ago

feldorn commented 1 year ago

Is there an existing issue for this?

Current Behavior

Calibre is configured to use a subfolder and is sitting behind SWAG/NGINX. The configuration worked on the prior version, but with KasmVNC produces the error message below.

Configurations Tested:

I can launch the URL for /calibre/vnc/dist/main.bundle.js and it is visible to the browser.

Swag NGINX Reverse Proxy is configured per the latest SWAG sample file.

image

Expected Behavior

Ability to Launch Calibre using an url with a subfolder: Example: https://www.domain.com/calibre/

Steps To Reproduce

  1. Configure SWAG and Reverse Proxy using all the defaults for Calibre
  2. Configure Calibre Docker Container and use the SUBFOLDER variable to define a subfolder
  3. Launch

Environment

- OS: Linux Mint 24
- How docker service was installed: Docker Compose

CPU architecture

x86-64

Docker creation

Docker Compose:
calibre:
  image: lscr.io/linuxserver/calibre:latest
  container_name: calibre
  environment:
    - PUID=1000
    - PGID=1000
    - TZ=America/Chicago
    - PASSWORD= #optional
    - CLI_ARGS= #optional
    - SUBFOLDER=/calibre/
    - DRINODE=/dev/dri/renderD128
  security_opt:
    - seccomp:unconfined
  ports:
    - 9085:8080
    - 9086:8081
  restart: always

Container logs

[migrations] started
[migrations] no migrations found
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1000
User GID:    1000
───────────────────────────────────────
**** adding /dev/dri/renderD128 to video group render with id 109 ****
[custom-init] No custom files found, skipping...
[ls.io-init] done.
_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
Xvnc KasmVNC 1.1.0 - built Apr  9 2023 00:38:52
Copyright (C) 1999-2018 KasmVNC Team and many others (see README.me)
See http://kasmweb.com for information on KasmVNC.
Underlying X server release 12014000, The X.Org Foundation
Obt-Message: Xinerama extension is not present on the server
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-abc'
xvnc_get_formats
github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

thelamer commented 1 year ago

does it work with the trailing slash entered ? IE http://www.domain.com/calibre/

feldorn commented 1 year ago

The behavior is with the slash. The NGINX proxy rules will rewrite the URL with the trailing slash. I can force it without a slash using the port address (bypassing the reverse proxy), but as stated elsewhere, that gives an error. I'll update the original post to show the slash.

image

thelamer commented 1 year ago

So I have a solution, you can add the following to your reverse proxy conf: (this is just drop in see my notes below about collision with other apps)

location ^~ /websockify {
    # enable the next two lines for http auth
    #auth_basic "Restricted";
    #auth_basic_user_file /config/nginx/.htpasswd;

    # enable for ldap auth (requires ldap-server.conf in the server block)
    #include /config/nginx/ldap-location.conf;

    # enable for Authelia (requires authelia-server.conf in the server block)
    #include /config/nginx/authelia-location.conf;

    # enable for Authentik (requires authentik-server.conf in the server block)
    #include /config/nginx/authentik-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app calibre;
    set $upstream_port 6901;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    proxy_buffering          off;
}

This will work, but only for one GUI app, so if you are running anything else off of this base would need a unique path like:

location ^~ /calibre-websockify {

If the path is modified from that websockify path then on your client need to modify the connection settings in the sidebar:

subfolder

I'll get a PR for our example proxy confs with the drop in so people in the future don't run into this.

feldorn commented 1 year ago

I can confirm this solution works. I also include authentication (Organizr) w/in the Reverse Proxy configuration and that isn't causing any issues either. I don't have another GUI in the container, so I've not tested modifying the path.

I appreciate the fast turn around on this!