11-17-2017, 03:09 PM | #1 |
Wizard
Posts: 1,821
Karma: 28696612
Join Date: Sep 2017
Device: PW3, Fire HD8 Gen7, Moto G7, Sansa Clip v2, Ruizu X26
|
Need help: Using NGINX as reverse-proxy for Calibre
I am working to get Calibre reverse-proxied by NGINX webserver. The basic NGINX setup as presented in the documentation works well (note that NGINX is hosted on 10.192.0.26 and calibre-server is running on a different computer, 10.192.0.2):
Code:
server { listen 80 default_server; server_name localhost 10.192.0.26; proxy_set_header X-Forwarded-For $remote_addr; location /calibre/ { proxy_buffering off; proxy_pass http://10.192.0.2:8080$request_uri; } location /calibre { rewrite /calibre /calibre/ permanent; } } Code:
calibre-server --url-prefix /calibre --num-per-page=999 --port 8080 Currently, if I go to http://10.192.0.26/calibre (that's the NGINX server URL) then it jumps to http://10.192.0.2:8080/calibre (that's the calibre-server URL). Great. But what I want is if the user enters this: Code:
http://10.192.0.26/calibre Code:
http://10.192.0.2:8080/calibre/#library_id=Calibre&panel=book_list&sort=author_sort.asc,series.asc&vl=Novels I know I could just have them bookmark the full URL (including fragment) that I am proposing to rewrite above. But this is something I think I should be able to do automatically in NGINX. But being new to NGINX, I don't know how. In a nutshell: If user hits NGINX with generic (no fragment at the end of the URI) http://10.192.0.26/calibre, then rewrite to add the fragment that defines my preferred library/vl/sort. But if user hits NGINX with a Calibre URI with a fragment on the end, then leave it as-is and don't try to rewrite. After getting this rewrite fixed, next up I will use my DDNS name, httpS with LetsEncrypt cert, and client cert authentication. One step at a time though. I'm just working on the rewrite and basic reverse proxy stuff first. |
11-17-2017, 07:09 PM | #2 |
Wizard
Posts: 1,821
Karma: 28696612
Join Date: Sep 2017
Device: PW3, Fire HD8 Gen7, Moto G7, Sansa Clip v2, Ruizu X26
|
After doing more research, I see why my attempts thus far have no worked.
In the following: Code:
http://10.192.0.2:8080/calibre/#library_id=Calibre&panel=book_list&sort=author_sort.asc,series.asc&vl=Novels So while I initially thought this should be something I could do in NGINX, I am not so sure now. I will have to do more research. But if anyone here knows the answer, I'd love some advice/suggestions. Thanks. p.s. Maybe I can do something with a 301 redirect sent back to the client. I'll trying messing around with that. The thing is, if these fragments are not sent to the server, then NGINX would not know if the client is hitting it "naked", or with a fragment. So NGINX would not know if it should pass the request through (if it already had a fragment), or rewrite/redirect it with a 301 (if it was "naked"). Hmmm... Last edited by haertig; 11-17-2017 at 07:15 PM. |
Advert | |
|
11-17-2017, 07:20 PM | #3 |
creator of calibre
Posts: 44,711
Karma: 24967300
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yes, fragments translate into ajax api calls made by the client to the server. The contents of the ajax calls are controlled by the fragment. They are not in any way processed by the server. So redirecting to them in a proxy is not going to work.
|
11-18-2017, 05:06 PM | #4 |
Wizard
Posts: 1,821
Karma: 28696612
Join Date: Sep 2017
Device: PW3, Fire HD8 Gen7, Moto G7, Sansa Clip v2, Ruizu X26
|
Why not simply this:
Code:
server { listen 80; location /calibre { proxy_buffering off; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://10.192.0.2:8080$request_uri; } } Code:
server { listen 80; proxy_set_header X-Forwarded-For $remote_addr; location /calibre/ { proxy_buffering off; proxy_pass http://10.192.0.2:8080$request_uri; } location /calibre { rewrite /calibre /calibre/ permanent; } } I have tested with these URLs: Code:
http://10.192.0.26/calibre http://10.192.0.26/calibre/ http://10.192.0.26/calibre/#library_id=Calibre&panel=book_list&sort=author_sort.asc,series.asc&vl=Novels [ Note: 10.192.0.26:80 runs the NGINX reverse proxy (Raspberry Pi3/Raspbian), 10.192.0.2:8080 runs the caliber-server (LinuxMint18 Sarah) ] |
11-18-2017, 06:00 PM | #5 |
Wizard
Posts: 1,821
Karma: 28696612
Join Date: Sep 2017
Device: PW3, Fire HD8 Gen7, Moto G7, Sansa Clip v2, Ruizu X26
|
Hold on. It looks like Calibre stores local data that makes it APPEAR that things are working, even when they are not. So my above tests were not valid. If I clear all Calibre local data, I get quite different results (errors). I need to clear out all Calibre data (more than just cache and cookies) between each test.
|
Advert | |
|
11-18-2017, 09:54 PM | #6 |
creator of calibre
Posts: 44,711
Karma: 24967300
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Yes, the content server is designed to work offline as well, which is why the home page does not show a list of books in a library but a list of books that have been opened and stored locally.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre-server reverse proxy issues | dom134 | Related Tools | 12 | 05-30-2016 05:39 PM |
Nginx Calibre Proxy | Ackis | Calibre | 2 | 04-19-2016 02:48 PM |
Aldiko + Calibre-Server + Reverse Proxy | dummkauf | Related Tools | 4 | 02-02-2016 03:55 PM |
need help with reverse proxy server | novaris | Devices | 1 | 09-10-2012 01:22 PM |
Content Server with Apache Reverse Proxy | Caleb666 | Calibre | 1 | 08-29-2011 05:20 PM |