-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] 404 For All Books When Downloading Files #21
Comments
Sorry to hear about that. There's no reason in general why a configuration like this shouldn't work with the current release, but as usual the issue might be in the details - especially the part where COPS and nginx have to work together to serve the right file. First of all, I saw from linuxserver/docker-cops#44 that on the linuxserver side you had to upgrade some nginx configuration files - makes sense, since there have been quite some changes there since 2018, and it's independent of COPS or any other PHP application deployed behind it :-) Since the rest of COPS works fine for you, I'm guessing these configuration changes worked OK for the most part - but you might share some of the details there if you have the time, so the next person knows where to start... Secondly, looking at your config_local file three things jump out which might cause some problems: For b. and c. you'll notice at the bottom of fetch.php that COPS basically either tells nginx which file to send, or it sends the file itself using the standard PHP readfile(...) function, depending on whether you have $config['cops_x_accel_redirect'] in your config (= your case) or not (= default). And it only does that for the books themselves - so it could very well be that images, thumbnails etc. work fine even with the multiple database setup but downloading the file doesn't. Is that what happens here? One other thing - the internal directory thingie isn't actually used in code anymore since the 1.1.3 release, but it used to do the necessary (re-)mapping of where PHP finds things on the filesystem, compared to where nginx locates things via internal redirects. Which means that now for your configuration, your nginx files should have something like that for each of your databases:
and that if you browse directly to one of these files yourself in your browser (not via COPS), you should get back the right file too. If you get a 404 error there, you know where the problem is - the mapping of the redirect location to the actual directory in the nginx configuration file. It's worth checking out :-) It would also help if you could access the nginx error log file to see what it's trying to send, or where COPS told it to redirect to.... |
About the other things you noticed: a. about the 502 error when you remove cops_x_accel_redirect That would be my default recommendation too - that way you wouldn't need any extra nginx configuration. Do you have any specifics about that 502 error, and does it apply only for books or COPS in general? Because this sounds more like you have a typo in config_local - the option is not set in there by default anyway, so it shouldn't generate any errors... b. the use_url_rewriting setting should still work in in the sense that it should re-write the fetch.php?data={id}&... URLs for books (and only them) to something like download/{id}/The%20Title.epub in COPS. Now whether nginx can then actually serve those download/... files will depend on the nginx config files again... You'd need to have some location /download/ with a rewrite to fetch.php in there to handle it - see https://github.com/seblucas/cops/wiki/Full-example-with-Nginx But this rewrite is mainly needed for older Kobo devices and in your case you're already letting ngninx send back the book, so there's little point in adding yet another layer of redirection in there... |
Corrected the example above - you have an extra /files in your internal directories |
Is there any working example on your fork of multi-database instances?
Book covers are not working on the prior version, but serving of files is which is all I've really cared about.
So are you saying that I should remove those clauses from I found
I have tried both configurations which you suggested both replacing
What do you mean by browsing directly to this? Going to something like I think I may have found the problem though! Something either in the prior fork of COPS itself or at least in the code that was making the multi-database code I stole from somewhere work required the layout of the mapped folder to be:
Essentially with the metadata.db symlinked one folder up from where the actual calibre library is in a way that Calibre doesn't actually create on it's own. So the path getting generated is instead of Edit: Looks like you noticed the /files thing too while I was writing my response |
Ok, moving the junction up and removing the use of the /files folder appears to have solved things. For reference @mikespub I did try your revised suggestion but it was producing results like this:
with rewriting on and this without:
so I figured I'd restructure the target folders as the extra complication no longer seemed necessary and that appears to have worked. For anyone folowing after the final working configs are as such: With the individual libraries actually mounted into For
For
Oh and as a bonus it fixed all of the cover images which hadn't been working too. |
Excellent, thanks :-) As far as other multiple database setups go, I don't use them myself in practice, but they're part of the normal COPS test suite that I run on nearly every commit. From your initial description, it didn't sound like point a. above would be the actual problem, but I thought I'd start with it because it does add a potential issue if I missed a db=... parameter somewhere. One thing the tests don't cover is the possible configurations with nginx unfortunately, so using a standard file structure now does help indeed. And yes, you even get your covers back :-) |
In case anyone else is reading this who is using lighttpd, I have found you need to add the following to your
|
So the maintainers of the LinuxServer Docker container for COPS have switched to this branch which is broadly good but I've been unable to get downloads of books working ever since linuxserver/docker-cops/issues/44
checkconfig.php
looks fine across the board and I've now updated all of the config files exceptingconfig_local.php
which points the app towards my specific libraries.Browsing the collection all works just as expected on both
index.php
andfeed.php
but all book download attempts 404Is there something I need to know/change in that config versus the old version/branch?
Note: I've tried it with
cops_use_url_rewriting
set to both1
and0
without any appreciable differenceHere's my
config_local.php
:Edit: I've also tried not setting
cops_x_accel_redirect
but that results in a 502 error instead of the prior 404The text was updated successfully, but these errors were encountered: