Skip to content

Commit af576de

Browse files
authored
Merge pull request #72 from mikespub-org/redirect_front
Update redirect location and use front controller
2 parents 8c1b832 + 291463f commit af576de

3 files changed

Lines changed: 34 additions & 13 deletions

File tree

readme-vars.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ param_ports:
5757
# application setup block
5858
app_setup_block_enabled: true
5959
app_setup_block: |
60-
Access the webui at `http://<docker host ip>:80`. For connecting via OPDS on a mobile device use `http://<docker host ip>:80/index.php/feed`. It is strongly suggested that you reverse proxy this prior to exposing to the internet. For more information, such as requiring credentials, check the COPS Wiki (linked above).
60+
Access the webui at `http://<docker host ip>:80`. For connecting via OPDS on a mobile device use `http://<docker host ip>:80/index.php/feed` or `http://<docker host ip>:80/feed`. It is strongly suggested that you reverse proxy this prior to exposing to the internet. For more information, such as requiring credentials, check the COPS Wiki (linked above).
6161
6262
The linuxserver version gives you access to `config/local.php` in `/config` to customise your install to suit your needs, it also includes the dependencies required to directly view epub books in your browser.
6363
# init diagram
@@ -114,6 +114,8 @@ init_diagram: |
114114
"cops:latest" <- Base Images
115115
# changelog
116116
changelogs:
117+
- {date: "10.06.26:", desc: "Existing users should verify: site-confs/default.conf and config/local.php - Update redirect location and use front controller."}
118+
- {date: "08.02.26:", desc: "Existing users should update: site-confs/default.conf - Deny access to all dotfiles."}
117119
- {date: "08.02.26:", desc: "Adding missing php-tokenizer package."}
118120
- {date: "10.10.25:", desc: "Adding missing icu-data-full package."}
119121
- {date: "10.07.25:", desc: "Rebase to Alpine 3.22."}

root/defaults/config/local.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
*/
3636
$config['cops_x_accel_redirect'] = "X-Accel-Redirect";
3737

38+
/*
39+
* Map /books/ to internal redirect location for COPS 4.2+
40+
*/
41+
$config['cops_x_accel_mapping'] = [
42+
'/books/' => '/_redirect_/',
43+
];
44+
3845
/* Enable cache folder
3946
* especially useful for lower power hosts
4047
*/
@@ -100,8 +107,6 @@
100107
* - Nginx: nginx.conf
101108
* - PHP built-in: router.php
102109
* - ...
103-
*
104-
* @todo update nginx/site-confs/default.conf.sample to make use of front controller
105110
*/
106-
$config['cops_front_controller'] = '';
107-
//$config['cops_front_controller'] = 'index.php';
111+
//$config['cops_front_controller'] = '';
112+
$config['cops_front_controller'] = 'index.php';

root/defaults/nginx/site-confs/default.conf.sample

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Version 2025/07/10 - Changelog: https://github.com/linuxserver/docker-cops/commits/master/root/defaults/nginx/site-confs/default.conf.sample
1+
## Version 2026/02/10 - Changelog: https://github.com/linuxserver/docker-cops/commits/master/root/defaults/nginx/site-confs/default.conf.sample
22

33
server {
44
listen 80 default_server;
@@ -31,11 +31,6 @@ server {
3131
expires 31d;
3232
}
3333

34-
location /books {
35-
root /;
36-
internal;
37-
}
38-
3934
location ~ ^(.+\.php)(.*)$ {
4035
# enable the next two lines for http auth
4136
#auth_basic "Restricted";
@@ -48,8 +43,27 @@ server {
4843
include /etc/nginx/fastcgi_params;
4944
}
5045

51-
# deny access to .htaccess/.htpasswd files
52-
location ~ /\.ht {
46+
# use internal redirect location for X-Accel-Redirect - do not use /books/ or other COPS urls with front controller
47+
location /_redirect_/ {
48+
internal;
49+
alias /books/;
50+
}
51+
52+
# use front controller for COPS 4.2+
53+
location ~ ^/(?!(index\.php|_redirect_)) {
54+
try_files $uri /index.php$request_uri;
55+
}
56+
57+
# deny access to all dotfiles
58+
location ~ /\. {
5359
deny all;
60+
log_not_found off;
61+
access_log off;
62+
return 404;
63+
}
64+
65+
# Allow access to the ".well-known" directory
66+
location ^~ /.well-known {
67+
allow all;
5468
}
5569
}

0 commit comments

Comments
 (0)