Caddy in a docker container, configurable via a simple web UI
-
Create a
/opt/Caddyfile
file on the Docker host# Caddy config, for a more information, see: # https://caddyserver.com/docs/caddyfile :80 { gzip log stdout proxy / example.com }
-
Run the container
$ docker run \ --name caddy \ -d \ -p 58080:8080 \ -p 80:80 -p 443:443 \ -v /opt/Caddyfile:/etc/Caddyfile \ -v /opt/caddy:/root/.caddy \ --log-opt "max-size=100m" \ -e "HTTP_USER=foo" \ -e "HTTP_PASS=bar" \ --restart always \ jpillora/caddy
-
Visit
http://<docker-host-ip>:58080
, authenticate withfoo/bar
and you should see
-
You now have an HTTP web server running at
http://<your-hostname>
-
Using your DNS provider, create A record:
<docker-host-ip>
to<your-hostname>
-
Change
:80
tohttps://<your-hostname>:443
, and add a new linetls <your-email>
above thegzip
line, then Restart -
You now have an HTTPS web server running at
https://<your-hostname>
Extras
- Bind the web UI to an internal IP address
-p <internal-ip>:58080:8080
and then it might be safe to removeUSER
/PASS
Copyright © 2017 Jaime Pillora <dev@jpillora.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.