seblucas / cops

Calibre OPDS (and HTML) PHP Server : web-based light alternative to Calibre content server / Calibre2OPDS to serve ebooks (epub, mobi, pdf, ...)
http://blog.slucas.fr/en/oss/calibre-opds-php-server
GNU General Public License v2.0
1.41k stars 229 forks source link

COPS for Synology; package 1.0.0RC2-3; open() failed downloading #354

Open stefanogithub opened 7 years ago

stefanogithub commented 7 years ago

Hi everybody. I'm running DMS 6.1.1-15101 Update 2 on a NAS-Synology. Installed COPS package 1.0.0RC2-3 from SynoCommunity. I'm able to browse all ebooks but i can't download ebooks. Downloading i get the following errror 2017/05/17 23:48:43 [error] 10040#10040: *210 open() "/var/services/web/cops/download/3/title.pdf" failed (2: No such file or directory), client: 192.168.1.101, server: , request: "GET /cops/download/3/A+40+anni+-+Sconosciuto.pdf HTTP/1.1", host: "nas-camker", referrer: "http://servername/cops/index.php?page=3&id=5" 2017/05/17 23:48:43 [error] 10040#10040: *212 open() "/var/services/web/missing" failed (2: No such file or directory), client: 192.168.1.101, server: , request: "GET /missing HTTP/1.1", host: "nas-camker", referrer: "http://servername/cops/download/3/titolo.pdf" is a configuration problem ? (what's file have to configure? how?) is a permission problem ? is a php problem ? (i tried to find php .log on NAS-Synology but i was not able to find)

Thanks in advance for any help or sugestions. Regards, Stefano

marioscube commented 7 years ago

Are you trying to download in a browser like firefox or to an e-reader like a kobo?

stefanogithub commented 7 years ago

hi marioscube, i'm trying to download in a browser

marioscube commented 7 years ago

Do you have url_rewriting enabled in config_local.php? If 1 then set 0.

/*
 * use URL rewriting for downloading of ebook in HTML catalog
 * See Github wiki for more information
 *  1 : enable
 *  0 : disable
 */
$config['cops_use_url_rewriting'] = '0';
seblucas commented 7 years ago

+1 for marios's answer. URL rewriting with latest DSM need some tweaking.

stefanogithub commented 7 years ago

@seblucas may you share tweaking for latest DSM ?

seblucas commented 7 years ago

I never done it myself, I just remember seeing one page about that. Still I don't remember DSM's version.

I never used COPS on DSM (except to test some installation) so I never had to look for answers ;)

LwsBtlr commented 6 years ago

I am getting a similar error (a 404) but mine looks like ….com/fetch.php?data=1396&type=epub&id=593 and I already have $config['cops_use_url_rewriting'] = "0" set in config_local.php.

my cops install is in /volume1/web/cops/ and the calibre folder is at /volume1/web/Calibre/ and configcheck is happy. (DSM 6.2-23739 up=to=date)

Kuzorra22 commented 4 years ago

Howdy !

Any update on this ?

YOS, Markus

Kuzorra22 commented 4 years ago

Just when you start asking ...

I had a breakthrough. With this additional config for NGINX in /etc/nginx/conf.d/www.cops.conf :

location ~ ^/cops/download/ { rewrite ^/cops/download/(\d+)/(\d+)/..(.)$ /cops/fetch.php?data=$1&db=$2&type=$3 last; rewrite ^/cops/download/(\d+)/..(.)$ /cops/fetch.php?data=$1&type=$2 last; break; }

A call to ;

http://XXX.XXX.XXX.XXX/cops/download//BUCH.

Will be translated to :

http://XXX.XXX.XXX.XXX/cops/fetch.php?id=&type=

Which is exactly what I need.

... unlesss I start calling my library with the virtual hostname :

I added :

location ~ ^/download/ { rewrite ^/download/(\d+)/(\d+)/..(.)$ /fetch.php?data=$1&db=$2&type=$3 last; rewrite ^/download/(\d+)/..(.)$ /fetch.php?data=$1&type=$2 last; break; }

to the file mentioned above and called:

https://ebooks.domain/download//BUCH.

but it results in an 404:

2020/05/26 18:05:12 [error] 1097#1097: 6021 open() "/volume1/web/cops/download//BUCH." failed (2: No such file or directory), client: XXX.XXX.XXX.YYY, server: ebooks.domain, request: "GET /download//BUCH. HTTP/2.0", host: "ebooks.domain", referrer: "https://ebooks.domain/index.php?page=7&id=123" 2020/05/26 18:05:12 [error] 1097#1097: 6021 open() "/volume1/web/cops/missing" failed (2: No such file or directory), client: XXX.XXX.XXX.YYY, server: ebooks.domain, request: "GET /missing HTTP/2.0", host: "ebooks.domain", referrer: "https://ebooks.domain/download//BUCH."

I think, the second one is a subsequent error, which can be ignored. SSL config and domain resulution work like charm.

Any ideas ?

marioscube commented 4 years ago

I'm a fellow user and I have COPS working the way I want it to, but ... I can't use Synology DSM 6 (my device only works with DSM 5) to help you test.

Just 1 or 2 questions:

Kuzorra22 commented 4 years ago

Howdy !

I just yesterday download the latest cops 1.1.3.

$config['cops_use_url_rewriting'] = "1";

That is all I did to my cops config.

YOS, Markus

marioscube commented 4 years ago

Do you need url_rewriting? What if you try without?

Can you check if mod_rewrite is enabled on your Synology?

I will try do do some tests with my old, old Synology (DS110j) with DSM 5.2 tomorrow.

marioscube commented 4 years ago

I just confirmed what I suspected yesterday: I cannot reproduce your error with or without $config['cops_use_url_rewriting'] = "1";

But, I'm on DSM 5 not 6. It might make a difference. .......And I use Apache (httpd) and you NGINX. Another difference. However the creator of COPS uses (?) NGINX himself so it should just work.

Just a thought ..... what are the permissions on the library directories and the file inside it?

For testing set the relevant permissions in the calibre library to 777.

Kuzorra22 commented 4 years ago

Hello marioscube, I appreciate your efforts, but I think, you're on the wrong track. As I wrote the URL rewrite works in general, but not when accessing the page via the reverse proxy. I think, it is somewhere there in the depths of the nginx configuration, where the magic needs to take place. YOS, Markus

Kuzorra22 commented 4 years ago

Got it :

You need to find in /etc/nginx/app.d/server.webstation-vhost.conf your vhost and look for :

include /usr/local/etc/nginx/conf.d/<LARGE NUMBER/user.conf*;

Now copy the file /etc/nginx/conf.d/www.cops.conf I mentiond earlier to /usr/local/etc/nginx/conf.d//user.conf.cops (or make a link ...) and reload your nginx config. Now it is working !

Thanks for your patience !

marioscube commented 4 years ago

Great!

As I use apache I will not be using your solution.

Nevermind a lot of deleted text. I forgot something on my new Debian setup..

Enjoy COPS (and the fine weather at leat over here ;-) )