Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Related Tools

Notices

Reply
 
Thread Tools Search this Thread
Old 07-17-2015, 02:17 PM   #1
bzowk
Junior Member
bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.bzowk has met Morla.
 
Posts: 1
Karma: 19112
Join Date: Jul 2015
Device: iPad
How to Host Multiple Virtual Libraries On Single System With Reverse Proxy Support

Hey Guys -

Just recently started using Calibre and like it. One thing I enjoy is it's content server. Unfortunately, it only has minimal features to configure as it doesn't natively support SSL and doesn't allow switching between virtual libraries.

My Calibre setup is installed on Windows 8.1 x64 and I currently have 3 virtual libraries - Books, Magazines, and Tech Guides. I wanted to have a solution which did the following:
- Allowed remote access of all 3 of my virtual libraries
- Didn't require opening / memorizing multiple (TCP) ports
- Was secured by SSL and password protected
- Hosting was silent and started automatically with Windows - even if recently rebooted and no one was logged in

I was able to accomplish this using a variety of tools I've used in the past plus a bit of research. I thought I'd post what I did as I never did find a central location for all of the steps plus thought someone else may be interested. Below is how I set this up. Some parts assume you know the basics, but if you attempt it and have questions for parts not covered, please post and I'll be happy to try to help.

What's Required
- A Windows-based OS (for this guide)
- Calibre installed
- Apache Server 2.4 installed
- srvany.exe
Part of the "Windows Server 2003 Resource Kit Tools." Just download the pack, extract/install, and srvany.exe will be one of the files

During this process, I suggest keeping a fresh/clean Notepad / Word document open as a scratch pad. There will be parts where we will create command lines which will be referenced and pasted into places in later steps. It's much easier to copy/paste them than re-create

Part 1 - Create a CalibreServer.exe Command Line that Works for You
The first bit of information we need is to create and test a command line which will start Calibre's server with the parameters you want to use. Here is a list of the available parameters. The only one which is required for this process is "--url-prefix" There's plenty of documentation for how to create these commands including the document above, so I won't go into depth.

Once you have the command string you wish to use ready, make sure you test it by executing your calibreserver.exe command string. Once started, open a browser and verify that you may successfully connect using any parameters you specified in the string. Below is one of the strings I used:

calibre-server.exe --url-prefix /tech --max-cover --username MyUsername --password MyPassword --port 860 --with-library "D:\Calibre Libraries\Technical Reference"

The above string assumes that the path which calibre-server.exe has been added to Windows' Path and does the following:
- Starts a calibre server silently in the background
- Adds the URL prefix /tech to the end of the address
- Hosts the service on port 860
(I'd test by going to http://localhost:860/tech)
- Specifies that I want to host the library at the specified path

Proceed with creating and testing a string like the above for each of the virtual libraries you wish to host. These may all be running at once (and will be later on) When testing, you may stop them by Ending Task on them in Task Manager

Once you have all of the strings, copy / type each into your Notepad / Word for later

Part 2 - Creating Windows Services (One Per Hosted Library)
So that the servers start automatically - even when a user isn't logged on plus be able to start/stop them at will, we will create a Windows Service for each. This requires srvany.exe listed above

1. Create a New Windows Service
Open a command prompt as administrator. Enter the below command:
Code:
sc create "CalibreSVR Book" binpath="D:\Windows Resource Toolkit\srvany.exe"
- Replace the binpath to wherever you have srvany.exe located
- Replace "CalibreSVR Book" with whatever you wish to name your service
Keep in mind you will be creating a new service per library so name it to match the library it will be hosting

One you execute the string, a new service will be created. Modify the name of the service in the string and run it again to create the service for your next library. Repeat for as many libraries as you wish to host.

2. Open regedit (Start/Run, type "regedit" - enter) and browse to HKLM\SYSTEM\CurrentControlSet\Services
Inside of the Services key will be a key (folder) for each service on your computer. Locate the new one(s) you just created. For each of them, follow the below steps:
- Right click on the new service key (folder) and create a new "String" named "Description
- Edit the new Description string and type in a brief description of what the service it for
- Right click on the new service key (folder) again and create a new "Key" named "Parameters"
- Right click on the new Parameters key (folder) and create a new string named "Application"
- Edit the new Application string and paste in your first (or only) calibre-server.exe string we saved in Part 1

Repeat the above steps for each new service you created. For each, fill out the description and paste in the Application string to match. When done, it should look similar to the attached screenshot.

Once you are done, open Windows Services, locate your new services, Start, then open a browser to verify that they work. Once you stop the service, calibre-server.exe for that library should also be gone from task manager.

Once tested, be sure to set the service(s) to "Automatic" if you want them to automatically start when the computer boots. Personally, I have mine set to "Automatic (Delayed Start)" as I don't need them launched the second Windows boots and it saves time during the boot process.

Part 3 - Reverse Proxy Configuration Using Apache
There are multiple ways to set up Reverse Proxy and all can be tricky. I've found a couple of posts for how to do so on this forum, but believe in a simpler method. To be honest, I'm running out of time so for now will assume that you have Apache 2.4 for Windows installed, have installed it's Windows Service, have configured it for SSL, and have enabled required modules for SSL & Reverse Proxy.If not, leave me a message and I'll assist later

If the above is set up as noted, stop the Apache 2.4 service, then open httpd.conf in a text editor. You will then need to add the below section per library / service you are wanting to host.

Code:
<Location /tech>
order allow,deny
allow from all
ProxyPass http://localhost:860/tech
ProxyPassReverse http://localhost:860/tech
</Location>
- The first line of each section should match what you used as the "--url-prefix" per string.
- The port listed should match the port specified in the string
- The url entered should be the local site you may successfully visit with each the cooresponding Service started

As mentioned above, create the above section (all 6 lines) per Service / Library / Calibre String you created - each with a space in between.

Once done and you've verified all data is correct, save httpd.conf. It's important to know that each time you edit httpd.conf, you must Restart or Stop/Start the Apache 2.4 service for the changes to take effect!

Note: if using Reverse Proxy, and wishing to access your libraries from outside your local network, you do not have to forward the port for each library in your router - only 443 if using SSL or 80 if not using SSL.

You are now ready to test!
- Verify in task manager that no Calibre servers are running (assuming Services are stopped)
- Start your Calibre Services
- Verify that task manger lists a process for each
- Start the Apache 2.4 Service
- Verify you can visit the local sites using local port numbers
- Finally, verify that you may visit the Reverse Proxied sites

Apologies if the last section was brief. I meant to add much more detail, but ran out of time. If you have any questions whatsoever, please reply and I'll be happy to try to assist.

Hope it helps someone! Thanks!
Attached Thumbnails
Click image for larger version

Name:	calibrereg.png
Views:	580
Size:	17.3 KB
ID:	140333  
bzowk is offline   Reply With Quote
Old 08-04-2015, 07:38 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
The calibre user manual includes directions for reverse-proying calibre-server using apache, here: http://manual.calibre-ebook.com/server.html
It does assume the user already knows how to set up apache and any other services desired.

If there is any way you think those instructions can be improved, why not update the manual? (The manual's source code is in the calibre repository.)

Last edited by eschwartz; 08-04-2015 at 07:42 PM.
eschwartz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Libraries and multiple disks Giuseppe Chillem Calibre 1 09-03-2013 12:36 PM
Used to have multiple libraries, gonna change to a single one... gers1978 Library Management 9 05-31-2013 11:45 AM
libraries multiple vs single? crazyfrank Calibre 16 01-27-2013 08:15 PM
need help with reverse proxy server novaris Devices 1 09-10-2012 12:22 PM
I'm in the market: lightweight, multiple file formats, Linux host support KenJackson Which one should I buy? 11 10-25-2010 11:23 PM


All times are GMT -4. The time now is 02:44 AM.


MobileRead.com is a privately owned, operated and funded community.