1. Caddy version (caddy version
): 2.2.1
2. How I run Caddy:
As a Windows service set up by nssm, with the single parameter “run”. The Caddyfile is in the same directory alongside. The user has all necessary permissions
a. System environment:
Windows server 2019
b. Command:
As stated above - a Windows service with the command “caddy run”
c. Service/unit/compose file:
?
d. My complete Caddyfile or JSON config:
####################################################################################
# Top Matter
####################################################################################
{
email pwh@cassland.org
}
####################################################################################
# Sites
####################################################################################
thrall.cassland.org {
root * ..\cassland.org\html
basicauth /CherwellSingers/* {
cherwell JDJhJDE0JHBoRjNLQUFJTjNoWTMwSC80eVJBZXVFNHg0cnBRZGowNEZBSTJITFh6eURPLlZxbHVDdzA2
}
basicauth /Nic/* {
NBH JDJhJDE0JHo5WGN5eGZ6SkNiRlEwYmtaZjlMMWVMeE1rVWIwZjNCNGhDdXJvRGRjVWRxQ1I5V3ozcWpH
}
basicauth /scores2/* {
pauls JDJhJDE0JGZaLjhRbHVhUWpZZTVMZjhINHNKTGVpTFcyVEpMNDRZMWxTWXl2aEVJejYxREJVOXIzTVlD
}
@browsedirs {
path /Album*
path /images*
path /sounds*
path /Nic*
path /public*scores2
path /scores*
path /Varicam*
path /TascamMod*
}
file_server @browsedirs browse
file_server
encode gzip
uri /images/QCavi.jpg replace .jpg .php
uri /images/FireDog.jpg replace .jpg .php
php_fastcgi localhost:9128 #(php74nts)
log {
output file .\Logs\CLaccess.log
format single_field common_log
}
handle_errors {
@404 {
expression {http.error.status_code} == '404'
}
rewrite @404 /404.html
# rewrite @404 /New404.html
}
# handle_errors {
# rewrite * /{http.error.status_code}
# reverse_proxy https://http.cat
# }
}
####################################################################################
3. The problem I’m having:
Normal usage without authentication (i.e. with the basicauth directives commented out) works fine, whether serving files, browsing directories, or calling PHP.
However, if I include the basicauth directives and try to access the directories concerned, I get a blank page without a login request. For the request which is browsed the response is 301, and for the request with an index.html the response is 308.
4. Error messages and/or full log output:
2a02:8010:f01e:1:c153:d394:3126:9e3b - - [11/Nov/2020:20:08:31 +0000] "GET /CherwellSingers HTTP/2.0" 308 53
2a02:8010:f01e:1:c153:d394:3126:9e3b - - [11/Nov/2020:20:08:31 +0000] "GET /CherwellSingers/ HTTP/2.0" 0 0
[...]
2a02:8010:f01e:1:c153:d394:3126:9e3b - - [11/Nov/2020:20:42:07 +0000] "GET /Nic HTTP/2.0" 301 40
2a02:8010:f01e:1:c153:d394:3126:9e3b - - [11/Nov/2020:20:42:07 +0000] "GET /Nic/ HTTP/2.0" 0 0
5. What I already tried:
I have remade the basicauth directives and re-encoded the password hashes using Caddy as recommended.
I moved the basicauth directives from following the fileserver directives to preceding them.
Beyond this, I am at a loss what there is to try; this is a copy of a long-standing Caddy v1 site with the necessary Caddyfile changes, so I know the actual website files are good.
6. Links to relevant resources:
URLs as in the caddyfile
Thanks for any hints…
Paul