Skip to content

Full example with Nginx

mikespub edited this page Oct 16, 2024 · 6 revisions

Here is the nginx configuration file :

server {

    listen [::]:80;

    server_name opds.mydomain.com;

    access_log  /var/log/nginx/opds.access.log;
    error_log /var/log/nginx/opds.error.log;
    root   /var/www/opds;
    index index.php;

    #Useful only for Kobo reader
    location /download/ {
          rewrite ^/download/(\d+)/(\d+)/.*\.(.*)$ /index.php/fetch/$2/$1/ignore.$3 last;
          rewrite ^/download/(\d+)/.*\.(.*)$ /index.php/fetch/0/$1/ignore.$2 last;
          break;
        }

    #Can break loading the images - if you don't see anything, comment
    location ~ ^/images.*\.(gif|png|ico|jpg)$ {
          expires 31d;
    }
    #Can also break loading the images, comment if it happens
    location ~ .(js|css|eot|svg|woff|ttf)$ {
          expires 31d;
    }

    #Not necessarily correct, it depends on distro.
    location ~ ^(.+\.php)(.*)$ {
       fastcgi_split_path_info ^(.+\.php)(.*)$;
       if (!-f $document_root$fastcgi_script_name) { return 404; }
       #fastcgi_pass    unix:/tmp/fcgi.sock;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
       include /etc/nginx/fastcgi_params;
    }

    location /Calibre {
        root /home/calibre/Dropbox;
        internal;
    }
}

And the COPS's config/local.php :

if (!isset($config))
        $config = array();
  
    $config['calibre_directory'] = '/home/calibre/Dropbox/Calibre/';
    
    $config['calibre_internal_directory'] = '/Calibre/'; 

    $config['cops_full_url'] = 'opds.mydomain.com'; 
        
    $config['cops_x_accel_redirect'] = "X-Accel-Redirect";
    
    $config['cops_use_url_rewriting'] = "1";
    

}