Skip to content

Full example with Nginx

Dave edited this page Aug 13, 2018 · 5 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 feed.php;

    #Useful only for Kobo reader
    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;
        }

    #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$ {
       include /etc/nginx/fastcgi_params;
       fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;
       fastcgi_pass    unix:/tmp/fcgi.sock;
    }

    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";
    

}