1. Caddy version (caddy version
):
v2.0.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
2. How I run Caddy:
a. System environment:
OpenWrt 19.07.0, r10860-a3ffeb413b (x64)
b. Command:
caddy run
c. Service/unit/compose file:
cat /etc/rc.local
caddy run
exit0
d. My complete Caddyfile or JSON config:
www.mydomain.cc {
reverse_proxy * 10.0.0.1:8888
}
sub1.mydomain.cc {
reverse_proxy * 10.0.0.1:8082
}
sub2.mydomain.cc {
reverse_proxy * 10.0.0.2:1880
}
sub3.mydomain.cc {
reverse_proxy * 10.0.0.2:81
}
sub4.mydomain.cc {
reverse_proxy * 10.0.0.3:8081
}
sub5.mydomain.cc {
basicauth admin YWRtaW4= {
realm “Restricted”
/*
}
reverse_proxy https://10.0.0.3:8443 {
transport http {
tls
tls_insecure_skip_verify
}
}
}
3. The problem I’m having:
I am trying to put basic password authentication on a problematic HTTPS backend. See sub5 in the Caddyfile. As per my post yesterday the syntax and naming of the modules/directives is killing me yet again.
Also is it possible to reuse the authentication directive over multiple sites via a snippet? Yes I know it is bad security practice to hardcode “admin” as a username and password but this is merely a test for now. More advanced username and password schemas would be appreciated.
Further is there a way to get a full listing of directives and syntax outputs from Caddy via the command line? It would be great to have a better grip on this.and a complete list of the directives available from each module.
4. Error messages and/or full log output:
2020/05/13 17:42:07.633 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
5. What I already tried:
Base 64 Encode on password, multiple different syntaxes, orders, and reconfigurations. The results:
2020/05/13 11:40:08.268 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:22 - Error during parsing: unrecognized subdirective {
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 11:42:20.123 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:22 - Error during parsing: unrecognized subdirective {
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 12:41:41.821 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:22 - Error during parsing: unrecognized subdirective {
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 12:42:25.934 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:22 - Error during parsing: unrecognized subdirective {
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 12:43:21.400 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:21 - Error during parsing: unrecognized subdirective http.authentication.providers.http_basic
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 12:54:19.276 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘reverse_proxy’: Caddyfile:21 - Error during parsing: unrecognized subdirective basicauth
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 13:07:26.584 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘basicauth’: Caddyfile:17 - Error during parsing: Wrong argument count or unexpected line ending after ‘admin’
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 13:08:21.455 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘basicauth’: Caddyfile:17 - Error during parsing: Wrong argument count or unexpected line ending after ‘admin’
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 13:11:32.586 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘basicauth’: Caddyfile:17 - Error during parsing: Wrong argument count or unexpected line ending after ‘admin’
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 13:12:41.877 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘basicauth’: Caddyfile:17 - Error during parsing: Wrong argument count or unexpected line ending after ‘admin’
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 13:14:49.327 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 14:19:07.084 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 14:21:35.395 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
root@TMIWRT:~# caddy reload
2020/05/13 14:23:00.065 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 14:40:16.859 INFO using adjacent Caddyfile
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 17:39:53.406 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘basicauth’: Caddyfile:20 - Error during parsing: username and password cannot be empty or missing
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 17:42:07.633 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 17:42:45.310 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding salt: illegal base64 data at input byte 1”}
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 17:47:12.124 INFO using adjacent Caddyfile
reload: sending configuration to instance: caddy responded with error: HTTP 400: {“error”:“loading config: loading new config: loading http app module: provision http: server srv0: setting up route handlers: route 5: loading handler modules: position 0: loading module ‘subroute’: provision http.handlers.subroute: setting up subroutes: route 0: loading handler modules: position 0: loading module ‘authentication’: provision http.handlers.authentication: loading authentication providers: module name ‘http_basic’: provision http.authentication.providers.http_basic: base64-decoding password: illegal base64 data at input byte 4”}
root@TMIWRT:~# nano Caddyfile
root@TMIWRT:~# caddy reload
2020/05/13 17:49:09.621 INFO using adjacent Caddyfile
reload: adapting config using caddyfile: parsing caddyfile tokens for ‘basicauth’: Caddyfile:17 - Error during parsing: Wrong argument count or unexpected line ending after ‘YWRtaW4=’
root@TMIWRT:~#
6. Links to relevant resources:
For Humor: