View Single Post
Old 10-29-2010, 07:21 PM   #1
mmseng
Member
mmseng began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jan 2010
Device: Kindle
Content Server Library Selection (also vhosts/url error questions)

Hi there. After recently uninstalling/reinstalling Calibre and completely overhauling my library I've been trying to get it to work correctly with apache vhosts again (e.g. calibre.mydomain.com). Just as I was about to give up banging my head over it and go back to using www.mydomain.com/calibre I restarted Calibre and huzzah! out comes 0.7.25 with better support for this. Lo and behold! My vhosts config works without problems now! (mostly) Thanks devs.

Anyway, since I rebooted the whole setup I've been trying to be careful to keep only non-DRM'd books with accurate metadata in my library. I've not been so successful with the DRM restriction (as I've exhausted myself trying to crack the restrictions on my OWN damn Amazon/Kindle store-bought books), but I decided to use a second library (a feature I wasn't even aware Calibre had) as a kind of holding pen for books I've acquired but have not yet DRM-stripped or updated metadata for.

After I finally got the content server working the way I want I realized that it was showing me books from my holding-pen library and not my actual library. Apparently the content server only shows you books from the currently-active library. Is this correct?

If so, is there a way to make the content server only show a certain library, regardless of which library you're looking at in Calibre? Alternatively, would there be a way to specify which library you want to view when accessing the content server? If not I propose these features as suggestions.

----------------------------------

Secondly, now that I've got Calibre playing nice with vhosts using the ProxyPass directive, I'm wondering if I actually have a correct vhosts configuration. I've tried so many different configurations of Rewrite and ProxyPass that I've mixed myself all up. Here is what I have configured in Apache:

Code:
<VirtualHost *:80>
    ServerName calibre.mydomain.com
	ServerAlias cal.mydomain.com
	
	RewriteEngine On
	
	RewriteCond %{HTTP_HOST} ^cal\.mydomain\.com [NC]
	RewriteCond %{SERVER_PORT} ^80$
	RewriteRule ^(.*)$ http://calibre.mydomain.com$1 [L,R=301]
	
	<Location />
		ProxyPass http://calibre.mydomain.local:8085/
		ProxyPassReverse http://calibre.mydomain.local:8085/
	</Location>
</VirtualHost>
where, obviously, calibre.mydomain.com is my webservers external IP, and calibre.mydomain.local:8085 is the local address of Calibre's content server. The rewrite in use is purely to redirect cal.mydomain.com to calibre.mydomain.com (simply implementing best practices regarding domain canonicalization). Does this look right? The main reason I ask, is because I'm still getting a 502 (bad gateway) errors occasionally, seemingly randomly, when accessing different content server pages, and I don't know why.

----------------------------------

Thirdly, I used to have the following Rewrite directives (just above the ProxyPass chunk):

Code:
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_URI} !(.*)/$
	RewriteCond %{REQUEST_URI} !(.*)\.(.*)$
	RewriteRule ^(.*)$ http://calibre.mattseng.com$1/ [L,R=301]
which I use is several other vhosts for URL canonicalization. It takes URLs like www.mydomain.com/whatever and rewrites them as www.mydomain.com/whatever/, assuming the requested file does not include a period (which would indicate the request is for a file and not a directory).

Now, I used to use this with the old content server web interface, just because I used it in all my vhosts, even though you should really never be requesting a specific file or directory. However, now that the new web interface uses things like "/mobile", and "/browse/search?query=xxx", these directives actually break the content server. Why? Because it can handle requests for "/browse" and "/mobile", but apparently not "/browse/" or "/mobile/", which is what these directive would return when requesting without the trailing slash.

When you request a page with a trailing slash, or any non-existent page for that matter, the content server throws a (very ugly) 404:

Quote:
404 Not Found

The path '/ajwnd' was not found.

Traceback (most recent call last):
File "site-packages\cherrypy\_cprequest.py", line 606, in respond
File "site-packages\cherrypy\_cperror.py", line 227, in __call__
NotFound: (404, "The path '/browse/' was not found.")

Powered by CherryPy 3.1.2
Obviously a 404 is normal for missing resources, and it only makes sense if /browse is an actual file and not a directory (I don't actually know the internal structure of the content server files). But it seems to me that, ideally, a request for "/browse/" should be either exactly, or at least functionally equivalent to a request for "/browse". A penny for your thoughts on this.

P.S. Oh, and both Apache and Calibre are running on the same Win2008 64-bit system.

Thanks for reading what turned out to be a ridiculously long post, and more thanks in advance for any help.
== Matt

Last edited by mmseng; 10-29-2010 at 07:33 PM.
mmseng is offline   Reply With Quote