Not able to proxy Calibre over nginx

Hi guys,

I have been playing around with the Docker images provided by LSIO and they are great. All of them are working fine except for Calibre, that I’m not able to proxy Calibre over nginx.

I have many other docker images being proxied without any problems (sonarr, qbitorrent, …) without any problem with the following format:

location ^~ /sonarr {
         proxy_pass h t t p : / /$host:8989/sonarr;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }

But with Calibre I’m not able to make it work. I have tried many different proxies, but at the end, I always have the same type of error on the NGINX error log:

2021/06/23 00:29:34 [error] 43224#43224: *1 open() “/var/www/html/public/vendor/bootstrap/css/bootstrap.min.css” failed (2: No such file or directory), client: X.X.X.X, server: X . X . com, request: “GET /public/vendor/bootstrap/css/bootstrap.min.css HTTP/2.0”, host: “X . X . com”, referrer: “h t t p s : / /X . X . com/calibre-server/”
2021/06/23 00:29:34 [error] 43224#43224: *1 open() “/var/www/html/public/vendor/font-awesome/css/fontawesome.min.css” failed (2: No such file or directory), client: X.X.X.X, server: X . X . com, request: “GET /public/vendor/font-awesome/css/fontawesome.min.css HTTP/2.0”, host: " X . X . com", referrer: “h t t p s : / / X . X . com/calibre-server/”
the same with “/var/www/html/public/css/vdi.css”, “/var/www/html/public/vendor/guac/js/guac.min.js”, “/var/www/html/public/vendor/jquery/jquery.min.js” , “/var/www/html/public/vendor/popper/popper.min.js”, “/var/www/html/public/vendor/bootstrap/js/bootstrap.min.js”, “/var/www/html/public/js/rdp.js”, “/var/www/html/files”, “/var/www/html/public/vendor/shortcut/js/shortcut.js”

Is there anyone that can give me some light on what I’m not doing OK to be able to proxy calibre?

Thanks a lot!

this is what we use and have tested working with our SWAG container, it looks like you’re doing something home-grown, so you’ll likely need to compare your config against ours WITH the includes.

reverse-proxy-confs/calibre.subfolder.conf.sample at master · linuxserver/reverse-proxy-confs (github.com)

Hi Driz,

Many thanks for the answer. Yes, my nginx is home-grown, i’m still starting with containers and I don’t feel advanced enough to move the nginx to docker. Anyhow, I have downloaded the SWAG image and I’m looking into the confs.

Regards,

Nacho

Hi Driz,

Today I have had some more time to play with your solution proposed and I still have the same error.

I think that the error might be on the proxy pass, as with the rewrite instruction removes the /calibre from the request and then the system tries to serve everything from the default root, instead of sending it to the proxied service. These are some errors that I’m getting:

X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /calibre/ HTTP/1.1" 200 2106 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/bootstrap/css/bootstrap.min.css HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/bootstrap/js/bootstrap.min.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/shortcut/js/shortcut.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/css/vdi.css HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/font-awesome/css/fontawesome.min.css HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/js/rdp.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/popper/popper.min.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/guac/js/guac.min.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/jquery/jquery.min.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/popper/popper.min.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/bootstrap/js/bootstrap.min.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/vendor/shortcut/js/shortcut.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"
X.X.X.X - - [27/Jun/2021:18:19:57 +0200] "GET /public/js/rdp.js HTTP/1.1" 200 926 "h t t p s://X.X.com/calibre/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0"

Here is the conf file i’m using:

## Version 2021/05/18
# calibre does not require a base url setting

location /calibre {
    return 301 $scheme://$host/calibre/;
}

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

    # enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
    #auth_request /auth;
    #error_page 401 =200 /ldaplogin;

    # enable for Authelia, also enable authelia-server.conf in the default site config
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app Y.Y.Y.Y;
    set $upstream_port ZZZZ;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /calibre(.*) $1 break;
}

Can you test something for me?

Add a new environment variable to the calibre container SUBFOLDER=/calibre/ and recreate the container

And then use this proxy conf:

location /calibre {
    return 301 $scheme://$host/calibre/;
}

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

    # enable the next two lines for ldap auth, also customize and enable ldap.conf in the default conf
    #auth_request /auth;
    #error_page 401 =200 /ldaplogin;

    # enable for Authelia, also enable authelia-server.conf in the default site config
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app Y.Y.Y.Y;
    set $upstream_port ZZZZ;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}

Hi Aptalca,

Thanks you for your answer. This is the message I got the following error:

Cannot GET /calibre/

And if I go to the Calibre folder and query the logs, this is the error I got from them:

[ 10126.630] (EE) dbus-core: error connecting to system bus: org.freedesktop.DBus.Error.FileNotFound (Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory)

I think that the calibre does not like being in a subfolder…

Post your conf and compose yaml because I just did what I suggested above and it works when accessing at https://domain.com/calibre

Hi Aptalca,

Here are the calibre.subfolder.conf and the default conf files. These are the only ones I have modified, all the others are SWAG standar.

What about the calibre docker arguments?

Upppssss, sorry, I forgot. Here you can find the compose for Calibre and for Swag

you need to add the subfolder env var to calibre, not swag

Oh, shit, I will have to reread twice any message from now onwards, I look like an stupid, sorry. Let me try and I will let you know.

:frowning:

Hi Aptalca, Driz,

Many thanks for the help provided. I have done what you said and now I can see that the system redirects correctly to the calibre subfolder. I’m accesing without any problem the calibre now!!

1 Like