[Support] Linuxserver.io - COPS (Calibre OPDS PHP Server)


Recommended Posts

well, docker ps simply hung.

 

Maybe I wasn't patient enough, but I've been giving commands an hour or more to do something and I got impatient. I held down the power switch until it went down. :(

 

Thanks for trying.

 

We apologize for the hijacking and now return you to your regularly scheduled COPS thread.

Link to comment

well, docker ps simply hung.

 

Maybe I wasn't patient enough, but I've been giving commands an hour or more to do something and I got impatient. I held down the power switch until it went down. :(

 

Thanks for trying.

 

We apologize for the hijacking and now return you to your regularly scheduled COPS thread.

Yeah if docker ps wasn't instantaneous then something bad was going on.

 

Sent from my SM-T560NU using Tapatalk

 

 

Link to comment
  • 2 weeks later...

Just looking at the COPS source code, rather than the dockerfile code.  There is the ability to set users in the app natively.

 

    /*
     * Enable PHP password protection (You can use if htpasswd is not possible for you)
     * If possible prefer htpasswd !
     * array( "username" => "xxx", "password" => "secret") : Enable PHP password protection
     * NULL : Disable PHP password protection (You can still use htpasswd)
     */
    $config['cops_basic_authentication'] = NULL;

 

Edit that chunk and paste it into config_local.php to enable as detailed here.

 

Haven't tested this, and I'll take a look in the next few days at it, as it may require some docker modification, but if anyone gets it working in the meantime let me know so I can save a bit of time.

 

EDIT:

 

Tested this and it works.  So you could then forward the port to the router.  Not the most secure way of doing things but FAR less work than setting up a https encrypted browser and for the purpose of this container it may well be adequate.

 

$config['cops_basic_authentication'] = array('username' => 'chbmb', 'password' => 'sparklyballsisgrumpy');

 

OK, life is slowing down a bit, I've got the fires put out (literally), etc., so it's time to get back to this.

 

How do I get to said file to edit indicated line?

 

If I'm reading the "here" document correctly, htpasswd is the preferred method, but (if I'm reading your comments correctly) it requires an https browser be built into the container to deal with it, therefore PHP password protection is much easier.

 

If I wanted to create 2 users, I think I would do this:

$config['cops_basic_authentication'] = array('username' => 'chbmb', 'password' => 'sparklyballsisgrumpy', 'username' => 'sparkly', 'password' => 'chbmbisthebaldest');

Is that correct?

Link to comment

OK, life is slowing down a bit, I've got the fires put out (literally), etc., so it's time to get back to this.

 

Good to hear!  :o

 

How do I get to said file to edit indicated line?

It's the file called config_local.php which you will find in the appdata folder.  The way this program works is this:

 

In the application there is a config_default.php with a LOT of options for customising.  Most are far beyond most users needs, including my own.  However if any of these options are present in config_local.php then they supersede the corresponding option in config_default.php.  So you won't find that line in the config_local.php, you need to add it.  Be careful where you add it though as you need to make sure you don't bork the php syntax.

 

If I'm reading the "here" document correctly, htpasswd is the preferred method, but (if I'm reading your comments correctly) it requires an https browser be built into the container to deal with it, therefore PHP password protection is much easier.

 

Essentially there are two ways.  What I personally do is run an nginx or apache webserver on my Unraid box which has SSL implemented as well as authentication using .htpasswd.  The reason I do this is I run a lot of web facing services and some I would not consider running without them being well secured. COPS is then reverse proxied via this nginx/apache container and all security is implemented at the nginx/apache level, rather than on COPS. 

 

The other way is the method above, and if you're only wish is to allow your son access then this is a lot easier to do, albeit without the extra security.  One thing to remember is that as you're communicating over http then info isn't encrypted including passwords, so use unique passwords that you don't use for anything else.

 

If I wanted to create 2 users, I think I would do this:

$config['cops_basic_authentication'] = array('username' => 'chbmb', 'password' => 'sparklyballsisgrumpy', 'username' => 'sparkly', 'password' => 'chbmbisthebaldest');

Is that correct?

 

I'm currently on holiday and after a planned power cut my server hasn't rebooted correctly so I can't check this, afraid you're going to have to suck it and see....

 

PS:  I am indeed as far as I'm aware the baldest member of ls.io, although asshopo, our newest member may be follicularly challenged, I haven't yet asked him.  Sparklyballs retains the accolade of being the oldest and grumpiest....  ;D

Link to comment

I'm currently on holiday

Enjoy yourself, thanks for answering while holidaying, now stop it and enjoy yourself!

 

and after a planned power cut my server hasn't rebooted correctly so I can't check this, afraid you're going to have to suck it and see....

Sucked and seen, that format does seem to allow for multiple logins.

 

One of these days, I'm going to have to figure out the apache/nginx server and an SSL certificate. That sounds more difficult, but much, much more comforting.

Link to comment

Hmmm... may have spoken too soon...

 

It seems I can successfully start COPS with multiple users defined, but that it will only allow me to log in as one user - whoever logs in first is the winner, nobody else can.

 

here's what's in the log file:

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
error: Ignoring nginx because of bad file mode - must be 0644 or 0444.
error: stat of /var/log/messages failed: No such file or directory
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 10-adduser: executing...

-------------------------------------
_ _ _
| |___| (_) ___
| / __| | |/ _ \
| \__ \ | | (_) |
|_|___/ |_|\___/
|_|

Brought to you by linuxserver.io
We gratefully accept donations at:
https://www.linuxserver.io/index.php/donations/
-------------------------------------
GID/UID
-------------------------------------
User uid: 99
User gid: 100
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 20-config: executing...
[cont-init.d] 20-config: exited 0.
[cont-init.d] 30-keygen: executing...
using keys found in /config/keys
[cont-init.d] 30-keygen: exited 0.
[cont-init.d] 40-config: executing...
[cont-init.d] 40-config: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.

I'm gonna say y'all could do with some date/time stamping... :(

 

All in all, it looks like everything is loading up ok - I think the error in there may have been from when I missed a couple of commas between users - I wasn't checking the logs at that time, so I don't know which container restart that pertains to.

I am confused, however, the last entry (at the bottom, I presume that's the most recent), does not say that it's "making user provided files available at...". However, I stopped & restarted many, many times, and was able to get access to it from at least one user each time, so I'm not sure if that's related.

 

Is there any sort of log from COPS itself indicating what it's served and to whom?

 

Here is how I've got my users defined:

    $config['cops_basic_authentication'] = array('username' => 'a', 'password' => 'a'
					,'username' => 'b', 'password' => 'b'
					,'username' => 'c', 'password' => 'c'
					,'username' => 'd', 'password' => 'd'
					,'username' => 'e', 'password' => 'd'
					);

Anyone see any errors or typos in there?  Y'all want my IP address now that you know how easy my passwords are to crack?  ;D

 

Any other suggestions on getting this to work, or should I just scrap it and start figuring out an HTTPS solution that will cover all my externally exposed dockers?

Link to comment

Hmmm... may have spoken too soon...

 

It seems I can successfully start COPS with multiple users defined, but that it will only allow me to log in as one user - whoever logs in first is the winner, nobody else can.

 

I'm gonna say y'all could do with some date/time stamping... :(

 

All in all, it looks like everything is loading up ok - I think the error in there may have been from when I missed a couple of commas between users - I wasn't checking the logs at that time, so I don't know which container restart that pertains to.

I am confused, however, the last entry (at the bottom, I presume that's the most recent), does not say that it's "making user provided files available at...". However, I stopped & restarted many, many times, and was able to get access to it from at least one user each time, so I'm not sure if that's related.

 

Is there any sort of log from COPS itself indicating what it's served and to whom?

 

Here is how I've got my users defined:

    $config['cops_basic_authentication'] = array('username' => 'a', 'password' => 'a'
					,'username' => 'b', 'password' => 'b'
					,'username' => 'c', 'password' => 'c'
					,'username' => 'd', 'password' => 'd'
					,'username' => 'e', 'password' => 'd'
					);

Anyone see any errors or typos in there?  Y'all want my IP address now that you know how easy my passwords are to crack?  ;D

 

Any other suggestions on getting this to work, or should I just scrap it and start figuring out an HTTPS solution that will cover all my externally exposed dockers?

 

OK, now I've had a chance to look at this I've updated the container to implement user based config and COPS basic authentication, as shown here.

 

You WILL need to update the container for this to work.  As an aside, this is an awesome plugin to add some buttons to the bottom of your Unraid docker page to manage updates.

 

SgLqnnT.jpg

 

Essentially you need to create multiple copies of config_local.php.

 

For the first user "a" just add the line to the config_local.php file

$config['cops_basic_authentication'] = array('username' => 'a', 'password' => 'passwordfora');

 

For the second user "b" copy config_local.php and rename it config_local.b.php and add the line

$config['cops_basic_authentication'] = array('username' => 'b', 'password' => 'passwordforb');

 

for the third user "c" copy config_local.php and rename it config_local.c.php and add the line

$config['cops_basic_authentication'] = array('username' => 'c', 'password' => 'passwordforc');

 

etc etc....

Link to comment

Essentially you need to create multiple copies of config_local.php.

 

You know, I saw that part and it just didn't make much sense to me. I didn't want different configs for each person, I want everyone to have the same access. Guess I'm just not into my *nix enough for it to have sunk in.

 

This seems to be working now, thanks!

 

Hope you're still enjoying your holiday instead of worrying about us.  ;)

 

 

Potentially dumb question, though...

Now that I can pull this up on my phone & the epbureader seems to bring it up in Firefox mobile on my Android, how do I get it to turn pages? I've tried tapping on the page number, tapping in general on the right side of the screen, swiping right to left, bottom to top... I just seem to be stuck on page 1 of whatever book I open. :(

 

I guess I just wasn't tapping in the right place... sigh...

Link to comment
  • 4 weeks later...

Thanks for making this happen!

 

I've got this up and running just fine with its external port on 8092.

 

I've got kids in the Army and at college, and they want to be able to read books, too. Since they're not at home, how do I set this up for some sort of external access without just opening my server up to whatever little script kiddies are out there lurking?

I know how to poke a hole in the firewall, but how do I secure it?

Is there any provision for username/password anywhere?

If not, does anyone have any suggestions on how to go about making that work?

 

Enable ssh tunneling on your unraid box open sshd server.  Recent versions all come with sshd baked in.  Then forward a firewall port to your unraid server's ssh port which is 22 by default.  Then when you ssh into your unraid box from anywhere in the world you use ssh port forward tunnels to access any web interface or other ports like COPS.  Might require a bit of googling but it works well and is very secure as ssh is highly encrypted.  :D

Link to comment
  • 2 months later...

I don't think this technically falls under docker support for COPS, but maybe somebody here has a clue...

 

I'm having an interesting annoying issue. I can go to my COPS server from my PC (Win10), browse to a book, then either download it or (using the little eye icon) or read it in my browser. However, from a browser on my Android phone (Samsung Galaxy S5, Android 5.0) or tablet (ASUS Transformer, Android 4.x), when I click on either the epub or mobi link, it launches the download and I get a notification with the download icon and text that says "fetch", however, it stays at 0%.

 

Anybody have any idea why it won't download on Android when it does just fine on Windows? I've tried on my home WiFi, via 4G LTE, via work WiFi - it never downloads. I've left it running on both devices for the last 2 hours+ while I've been reading a different book, and neither has moved past 0%.

Link to comment

Hi Freeman,  I just tried and it works absolutely fine with a mobi file for me using Chrome or Firefox on my LG G4.  However using the browser that came with my phone it doesn't work.

 

Personally on my Android devices probably better off using something like moonreader and using the opds feed.

 

Sent from my LG-H815 using Tapatalk

 

Link to comment

Wow, weird. I tried it on my phone and it works just fine in Chrome. I've been a Firefox user for years, occasionally jumping to Chrome for short periods. Firefox seems to be getting rather heavy and bloated, and I've been contemplating switching again - this might be the impetus.

 

When you say "using the opds feed" does that mean the feed from Calibre itself running on the server? Is it possible to pwd secure it as I've managed to do with COPS? If not, I'll probably put that off until I've managed to get some better security set up.

 

Thanks, CHBMB!

Link to comment

Is it possible to pwd secure it as I've managed to do with COPS? If not, I'll probably put that off until I've managed to get some better security set up.

 

Thanks, CHBMB!

 

I use AI Reader on Android and it allows specifying a password when adding an OPDS library as I did for COPS: http://unraid:6060/feed.php.  I haven't tried using a password with COPS because my security is via openvpn or ssh tunnels but the underlying tech appears to support it.

Link to comment
  • 3 months later...

Hey y'all!

Did something change with the updates? None of the other users can log in anymore.

I had it set up with the different config files, but the only one that allows a login is the original config_local.php the others (ex.: config_local.xyz.php) just loop the username and password prompt.
 

Link to comment
18 minutes ago, deuxcolors said:

Hey y'all!

Did something change with the updates? None of the other users can log in anymore.

I had it set up with the different config files, but the only one that allows a login is the original config_local.php the others (ex.: config_local.xyz.php) just loop the username and password prompt.
 

 

Looks like it's a problem upstream in the application itself.

Link to comment
23 minutes ago, deuxcolors said:

Thank you Baldy.

EDIT: Is there an way to implement the proposed fix into the docker config file(s)? Just add a line, or wait for COPS to fix itself?

 

I've actually just put a comment on there, I'm surprised that nobody has made a PR, especially as the fix is known.  If there are no objections then I'll make a PR and once it's merged I'll talk to Seb and see if he'll push another release.

Link to comment
1 hour ago, deuxcolors said:

Thank you Baldy.

EDIT: Is there an way to implement the proposed fix into the docker config file(s)? Just add a line, or wait for COPS to fix itself?

 

I've put in a PR and tested it, the fix works.

 

If you want to apply the fix manually in the meantime

docker exec -it cops bash
nano /usr/share/webapps/cops/config.php

#Hit Ctrl + Shift + _ then enter 20 to take you to Line 20

Then change the line from

require_once dirname(__FILE__) . '/' . $user_config_file;

to

require dirname(__FILE__) . '/' . $user_config_file;

#Ctrl + x, then hit Y, then press return.

If you update the container before the fix makes it into the docker then you'll need to reapply the fix.

Link to comment
  • 3 months later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.