ajslater / codex

Codex is a web based comic archive browser and reader
GNU General Public License v3.0
202 stars 6 forks source link

Getting a 403 forbidden error on OPDS readers when trying to stream or download. #297

Closed tehguitarist closed 1 year ago

tehguitarist commented 1 year ago

Hi again and sorry for the two issues in as many days.

I run Codex on a Synology NAS using the Docker image. I am using Synology's built in reverse proxy to give HTTPS.

When I try to connect to the DDNS server through an OPDS reader, I get 403 Forbidden errors on streaming or downloading, but it seems to be pulling the feed fine (I can see all my comics). It's not a huge collection (~4k).

I also tested this locally with just http and the same result.

I just tested the OPDS feed from my Calibre-Web service and that worked ok.

Any thoughts or advice would be fantastic!

My NGINX config (generated by Synology) looks like this

`server { listen 9811 ssl default_server; listen [::]:9811 ssl default_server;

server_name _;

include /usr/syno/etc/www/certificate/ReverseProxy_bf3ef8e0-2239-4eb6-ab94-55e338b224af/cert.conf*;

include /usr/syno/etc/security-profile/tls-profile/config/ReverseProxy_bf3ef8e0-2239-4eb6-ab94-55e338b224af.conf*;

add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload" always;

proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;

location / {

    proxy_connect_timeout 60;

    proxy_read_timeout 60;

    proxy_send_timeout 60;

    proxy_intercept_errors off;

    proxy_http_version 1.1;

    proxy_set_header        Upgrade            $http_upgrade;

    proxy_set_header        Connection            $connection_upgrade;

    proxy_set_header        Host            $http_host;

    proxy_set_header        X-Real-IP            $remote_addr;

    proxy_set_header        X-Forwarded-For            $proxy_add_x_forwarded_for;

    proxy_set_header        X-Forwarded-Proto            $scheme;

    proxy_pass http://localhost:9810;

}

error_page 403 404 500 502 503 504 /dsm_error_page;

location /dsm_error_page {
    internal;
    root /usr/syno/share/nginx;
    rewrite (.*) /error.html break;
    allow all;
}

}`

tehguitarist commented 1 year ago

/The dev from Panels was kind enough to do some investigation and found some errors here:

https://community.panels.app/t/can-see-comics-from-opds-stream-codex-but-get-an-error-on-viewing-or-downloading/1794/3 I also have logs from him I can share privately if that would help.

one has to do with passing along authentication, the other is the image being passed as base64 which may be a synology error page due to not being able to get through.

This may or may not be related, but I also got a huge ram spike that locked down my NAS (2gb RAM, so not huge, but not totally awful) when trying to browse in the web ui. I did pull the latest docker image yesterday.

ajslater commented 1 year ago

Looking at it, I think this may be a codex bug with not the right authentication checks happening for the pages, downloads (and possibly cover images). I'll release a fix soon.

ajslater commented 1 year ago

Think i've fixed this in v1.3.8

tehguitarist commented 1 year ago

Looks to be working! Appreciate the quick fix. I've noticed thumbnails largely cache when I open files (and on a 2gb system it can take a minute). Is there any background tasks that can walk through and slowly get them overnight? Not a huge issue, I'm largely through cacheing it all, just wondering if I missed a task somewhere or overlooked it.

ajslater commented 1 year ago

There used to be one, but i disabled access to it. Maybe i'll make it accessible again in a forthcoming release.

Thanks for reporting this bug!