Hi I think this is a Caddy-related misconfiguration on my end or something silly. I tried to provide as much info as I can.
1. Output of caddy version
:
v2.5.2 h1:eCJdLyEyAGzuQTa5Mh3gETnYWDClo1LjtQm2q9RNZrs=
2. How I run Caddy:
As a development server reverse proxy on WSL in localhost, to expose some services under SSL while developing.
caddy run --config ./dev/Caddyfile
a. System environment:
I’m running Caddy on WSL 2 under Windows 11. Android version on phone is 12 and using latest Chrome on both machines. Problem experienced with Firefox Android too. Android connected through USB cable.
b. Command:
(Mentioned above, app and adb commands following)
c. Service/unit/compose file:
d. My complete Caddy config:
{
http_port 4432
https_port 4433
local_certs
}
localhost:4433
reverse_proxy /* localhost:8080
reverse_proxy /game/* localhost:3000
reverse_proxy /auth/* localhost:3000
Both /game and /auth routes are intended to be routed to port 3000 (aside: do you have a nicer syntax or that?)
3. The problem I’m having:
I’m trying to reach my localhost development web app under HTTPS through Caddy. It works on my desktop but not with Android using adb reverse tcp:4433 tcp:4433
. I think Caddy is the culprit because when I adb reverse tcp:8080 tcp:8080
which leads directly to one of the proxied apps, I do see it in the mobile browser just fine. I guess it’s some configuration thing with the SSL traffic.
I wish I could use curl
on adb shell
to get an exact message, but searching online it does not seem very trivial, so I tried nc localhost 4433
and also nc localhost 8080
. The former returns rather quickly and the latter hangs up (saw the this netcat nc
tip somewhere). Do you have a tip to give here to assist in debugging?
4. Error messages and/or full log output:
These logs are with the debug
directive added to the above settings
caddy run --config ./dev/Caddyfile
2022/08/16 14:59:27.202 INFO using provided configuration {"config_file": "./dev/Caddyfile", "config_adapter": ""}
2022/08/16 14:59:27.204 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["//127.0.0.1:2019", "//localhost:2019", "//[::1]:2019"]}
2022/08/16 14:59:27.205 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0xc000416150"}
2022/08/16 14:59:27.205 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2022/08/16 14:59:27.218 INFO pki.ca.local root certificate is already trusted by system {"path": "storage:pki/authorities/local/root.crt"}
2022/08/16 14:59:27.218 DEBUG http starting server loop {"address": "[::]:4433", "http3": false, "tls": true}
2022/08/16 14:59:27.218 DEBUG http starting server loop {"address": "[::]:4432", "http3": false, "tls": false}
2022/08/16 14:59:27.218 INFO http enabling automatic TLS certificate management {"domains": ["localhost"]}
2022/08/16 14:59:27.218 INFO tls cleaning storage unit {"description": "FileStorage:/home/amir/.local/share/caddy"}
2022/08/16 14:59:27.219 INFO tls finished cleaning storage units
2022/08/16 14:59:27.219 WARN tls stapling OCSP {"error": "no OCSP stapling for [localhost]: no OCSP server specified in certificate", "identifiers": ["localhost"]}
2022/08/16 14:59:27.219 DEBUG tls.cache added certificate to cache {"subjects": ["localhost"], "expiration": "2022/08/17 02:15:22.000", "managed": true, "issuer_key": "local", "hash": "5cbfe053d7be0c7ab253a59be76160395a965fe2b34dda02f3ade0d79d0e82e0", "cache_size": 1, "cache_capacity": 10000}
2022/08/16 14:59:27.220 INFO autosaved config (load with --resume flag) {"file": "/home/amir/.config/caddy/autosave.json"}
2022/08/16 14:59:27.220 INFO serving initial configuration
5. What I already tried:
- running
adb usb
and then reopening the ports withadb reverse tcp:4433 tcp:4433
- Just mentioning this setup works for the desktop machine through browser at
https://localhost:4433
- - regular traffic through port 8080 is working nicely with Android
- tried seeing access logs with stdout or file for caddy by following log (Caddyfile directive) — Caddy Documentation but I didn’t manage to see access logs, even from desktop - which works, so it’s strange
- I tried a port different than 4433 which didn’t seem to make a difference, even port 443 with
sudo caddy run ...
(works desktop, not mobile) - I tried closing Android Chrome and reopning it. Tried Android Firefox too. Same results.
- Tried using
localhost:4432
as it’s the http port in my Caddy config, didn’t forget toadb reverse
this port. Similar results (attached screenshots).
Here are screenshots of the error messages for both ports (empty response and connection closed )
edit: I can’t post multiple media items as a new user so instead I’ll mentioned that 4432 port said ERR_EMPTY_RESPONSE
Again, mentioning that localhost:8080 on Android works so the adb reverse
is not faulty
6. Links to relevant resources:
- 44997 - chromium - An open-source project to help move the web forward. - Monorail - failure to use SSL port other than 443, doesn’t seem to be the my problem thoughr