Caddy: Does caddy support online configuration via a remote API?

Created on 28 Apr 2015  路  21Comments  路  Source: caddyserver/caddy

I would like the ability to add and remove backends from a site hosted by Caddy. Is this possible today, if not any plans for the future?

discussion feature request

Most helpful comment

We have implemented this in Caddy 2.

All 21 comments

It's not possible today, but in the future, definitely yes. Caddy's middleware handlers are designed to be hot-swappable without having to restart the process. A remote management API is one of the primary goals, as well as a nice web UI.

I need to do some refactoring but those are the next major features I hope.

@kelseyhightower Okay, I'm starting on this. When you say "add and remove backends" are you referring to the proxy directive? What's on your API dream list?

@alfonsodev Just because I know you'd :+1: this.

@mholt I can't speak for @kelseyhightower but personally the top priority for me would be to remotely manage proxy, tls and websocket

Cool, I'll try to do those first. I'm cooking up some other neat things too that I'll be excited for you to try.

:+1: on a web-ui to configure and change common directives.

I have refactored a good portion of the server code to allow another package (the API) to change it. So far, new servers can be started and I have a few endpoints wired up that both get and post middleware configuration.

There is still lots to do, but I hope we'll have something to show within a few weeks.

Can the api support client TLS auth? I started using this pretty heavy with apis "docker/etcd" and it would be nice to standardize this as an auth option for the caddy api as well. I think you posted some material related to this recently on twitter.

At this point, I don't see why not. (As of the latest version, 0.7.1, Caddy supports TLS client auth.) I haven't decided on API authentication, but TLS client auth would not be the only way to authenticate.

An API service will not be allowed without TLS (unless it's only accessible to localhost).

Anyone interested in this may now try out an early prototype of the API - the details are in issue #111. It doesn't do much yet, but next on the list are endpoints for TLS and proxy configuration. Feel free to check it out and comment in that issue.

@mholt Awesome stuff so far.

I tried to find code on this feature but the api branch is gone (it was described why, I can see that) and there are no more hints on this.

Is there any progress on this?

Personally, I think a tiny web interface that only gives you the config file as a plain text to edit would be a pretty good start. The config file is so easy to read and manipulate anyway. Make that a directive and you can use any authentication directive anyway.

@sinni800 Yeah, we've been working on the front-end UI, and I actually have a file stashed locally here that implements a sort of API, for experimenting. But right now most of the effort has been going into the new site and build system... trust me, it's all worth the wait. :) Yes, the API will start simple. We'll build out from there.

Good to know, thanks :) Caddy is getting better and better. I threw Nginx out completely for my purposes

Any news on this? I am looking to dynamically add/remove backends to caddy reverse proxy via api

@kmanley I've been working with @mholt on this, though admittedly it took a back seat this summer because of my graduation and wedding 馃槄. We're back on it now though! Again, it'll be simple endpoints to start out, as we want to get the general structure out to the public ASAP. Out of curiosity, what's your use case? Is this a personal project or for a business, etc?

maybe we could setup some plans or todos or disscussion, people could join in @yroc92

I'd like to be able to dynamically add proxy entries to new docker containers that come up and down in a build pipeline app, simple as adding stanza such as:

pr-101.example.com {
    proxy / localhost:8101 {
        transparent
    }
}

Having a web ui is not a priority for me.

@pcj until this is available in Caddy, check out https://traefik.io/ which does service discovery

Quick update to this issue - there's now srv:// support for service discovery for both fastcgi and proxy (e.g. via Consul). In addition, there's a docker plugin that can be used as well.

We have implemented this in Caddy 2.

Was this page helpful?
0 / 5 - 0 ratings