-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest (2 hr ago) caddy/caddy docker image locks down admin API, regardless of config #71
Comments
Can you give more details? What's your full Caddyfile or JSON config? How did you run Docker ( |
I think this is the relevant section of the JSON config:
Before the rollback I was running the I don't know what numbered version that corresponds to. I only noticed because the image updated itself at some point and suddenly my other containers couldn't reach the Caddy admin API. I'll see if I can reproduce locally with minimal configuration before sharing the specifics of my deployment. I don't think it will require any special configuration, if I understand the issue correctly |
FYI, from now on you should use the Clear reproduction steps would be helpful, with |
same issue here. one console: anohter console: enter caddy container: |
I'm fairly certain that this is due to some changes in RC3:
The commit in question seems to be caddyserver/caddy@a3bdc22 @postgetme: I don't think you're having the same issue as @collinbachi - @collinbachi has the @collinbachi If your config isn't working, I have a feeling that the issues is with Caddy RC3 itself, not in the Docker image. @mholt I feel like the issue is in the |
@collinbachi can you clarify what you mean by that? which address specifically are you trying to reach the API at, and which which exact command? |
@collinbachi maybe post the output of a |
@collinbachi and your full Caddy configuration would be useful too 🙂 |
I suspect the reason is indeed because of that linked commit, however, it's impossible to know for sure without more info, I think curl -v will give us that information. By default, the admin endpoint only allows requests to the host to which the listener binds its socket; the default is To clarify, this is all about the default permissions. As a workaround, you can set the I'll need to decide if we change the current behavior or leave it as-is. If I change it, the only change I can think of would be to disable the Host header checking if binding to a wildcard interface, which is (mildly) less secure. If I leave it as-is, then you still get better security and can simply set the Does that make sense? Any thoughts? (Of course, this is all assuming my hunch is correct; hopefully curl -v will help us know for sure.) |
Yeah, that's what I had wondered, except shouldn't the |
No, that only affects CORS enforcement. The default is |
@mholt we should spend more time looking to improve the unix socket situation for admin (especially on Linux, Windows does seem to be a bit of a dead end there unfortunately). I think using a unix socket for the admin endpoint instead of E.g. if you specify a unix socket, when Caddy is stopped the unix socket file sticks around. Running Caddy again, it complains that the socket file already exists - Caddy should remove the socket when stopped. Also, as mentioned by someone else previously, the socket doesn't always have the right permissions on it. I'm pretty sure Caddy should set those to something sensible after starting. |
Ah! ok, maybe we need an |
It'd help with network security, to be sure, but sharing sockets can be a bit tricky with Docker. It's been a |
If we do change things, one possibility is to disable Host checking if binding to a wildcard interface and then emitting a warning in the logs. If you're allowing all network interfaces to connect to your admin endpoint, then you better know what you're doing, I guess?
I believe the admin endpoint does let you bind to a Unix socket. It should work in rc3, if it doesn't, let me know. But in my testing (on a mac) it works fine. |
Yes, the issues I'm describing is specifically related to that. It works on first run, but subsequent runs don't without manually deleting the socket |
That's weird... is that true of all unix sockets, and does that happenf or listen addresses for the HTTP server too? Might be worth an issue in the main repo to track that. (I guess I don't know much about how unix sockets work.) |
Re unix sockets opened an issue: caddyserver/caddy#3269 |
After further testing, I take this back. I can reach the admin API at the hosts listed in "origins". This resolves my issue, since I can whitelist the hostname I want to use to reach Caddy (which seems entirely reasonable to me, from a security perspective.) Thanks, and sorry for the misunderstanding! |
No worries, I just pushed a change that disables that check if you listen on the wildcard interface. I think it's reasonable if you go to the trouble to listen on an open interface (we also emit a warning in the logs). |
I was wondering if this was resolved or is there still work to be done upstream? I’m seeing the same issue using the latest build. Using docker-compose I can connect via 0.0.0.0 once |
@coatezy I think you want this fix: caddyserver/caddy@f5ccb90 which hasn't been released yet, but should be next week. |
Thanks @mholt. You are right, it was late and had been hitting my head against the desk for a good hour or so. I woke up this morning and realised you had implemented a fix. I confirmed that my setup did work with the RC2 release as mentioned in comments above and have since got everything working with RC3. It is good to know that the fix is being released soon. I now need to work out how to pump all logs to an HTTP endpoint so I can work out when certificates have been generated successfully or not, but thats another thing. |
That'll probably get easier with a later version of Caddy in the 2.x tree. |
My current workaround is to do something like this: CaddyConfig.json {
"admin": {
"listen": "0.0.0.0:2019"
}
} Dockerfile FROM caddy:2-alpine
COPY CaddyConfig.json /etc/caddy/
EXPOSE 80
EXPOSE 443
EXPOSE 2019
CMD caddy run --config /etc/caddy/CaddyConfig.json --resume Put then in the same folder then build my docker image. |
Yep @DrecDroid that's a perfectly reasonable approach. FYI, those EXPOSE lines don't actually do anything, they're essentially just comments to the reader. You still need to use |
Yes, of course. Then I have to run as usual but now I have the CaddyConfig.json as I needed. |
Still a little confused on this one. I'm attempting to pull metrics from localhost:2019/metics from a separate docker container on the same docker network - so the origin address is dynamic. What settings should I use in my caddyfile to enable access to that particular endpoint? If not could I use a proxy directive to achieve the same effect? Current Caddyfile:
docker-compose
and finally prometheus.yaml for good measure
|
@b3ntly you need to change the listen address to For next time, please ask your usage questions on the Caddy community forums. We prefer to keep the GitHub issue board for bugs and feature requests. Don't forget to fill out the thread template so we can help you! |
Expected:
I set enforce_origin to false, and I can reach the admin API at any origin. (https://caddyserver.com/docs/json/admin/#origins isn't explicit on the matter, but that's what I expect)
Actual:
I set enforce_origin to false, and I can't reach the admin API at any address other than the listening address.
Temporary solution:
Rolled back to
caddy/caddy:2.0.0-rc.2-alpine
and confirmed I could again reach the admin API remotely.The text was updated successfully, but these errors were encountered: