2021 update: This thread is a popular search result, but 5 years later, is now obsoleted because it was about Caddy v1. Please refer to our official documentation and latest wiki articles instead.
Please do not ask for help in this thread. Limit discussion to this FAQ only. Thanks!
How can I install Caddy from the command line?
The easiest way is to use curl
or wget
to install Caddy. Simply follow the instructions at getcaddy.com. (Note that custom builds may take several seconds or minutes before the download begins.) A plain install is as easy as:
$ curl https://getcaddy.com | bash
If the build server is down entirely, you can download static releases from GitHub.
Do I have to run Caddy as root to serve on port 80 or 443?
No. On Linux, you can use setcap
to give Caddy permission to bind to low ports. Something like setcap cap_net_bind_service=+ep caddy
should work. Consult the man pages of your OS to be certain. You could also use iptables to forward to higher ports, or use systemd for similar benefits.
It’s possible that a future version of Caddy will implement privilege de-escalation, but it will likely require spawning a new process.
Why does Caddy need ports 80 and 443?
These ports are required by the ACME specification to solve challenges for your TLS certificates. Even though your site is served over HTTPS on port 443, it needs port 80 to redirect HTTP traffic to HTTPS.
How do I run Caddy in the background?
Caddy is just like any other process or command.
You can run it in the background with nohup caddy &
. To keep Caddy running after system restarts, you might want to add a cron job like @reboot nohup caddy &
. However, individual needs and systems vary widely, so we (the project maintainers) expect you to know how to administer your system. You are of course welcome to discuss it on these forums.
How can I make a virtual host that serves files only under a specific path?
With Caddy 0.9+, site addresses can be scoped to a base path:
yoursite.com/path/ {
...
}
Can you translate my .htaccess or nginx.conf to Caddyfile?
First, consult the Caddy documentation for the directives you can use that might do what you need. If you still need help, feel free to ask on these forums. Make sure you show what you’ve already tried, and explain specifically what you’re stuck on!
Note that not all concepts of .htaccess or nginx.conf translate to a Caddyfile. Keep in mind that some settings are implicit with Caddy, and other features are not available at all (for better or for worse).
Why does Caddy take all my sites down if just 1 domain fails to resolve?
This is a common misunderstanding; Caddy doesn’t take your sites offline. When you are starting Caddy and there is an error with your configuration (for example, one of your domains is invalid), Caddy refuses to start, but that does not take your sites down; there are no sites to take down, since Caddy was not previously running. When you reload a new configuration by signaling USR1, Caddy rolls back to the previous working configuration if the new one is invalid, which keeps your existing sites online with zero downtime. Read more in this thread.
What is the best way to run a Python site with Caddy?
For now, use the proxy
directive to reverse-proxy to a WSGI web server such as uWSGI or Gunicorn. There has been plenty of interest building WSGI support into Caddy, so if anyone implements this in pure Go, you may not have to proxy like this forever.
How do I take advantage of multiple CPU cores with Caddy?
Whether your site is busy and big or slow and small, Caddy will take care of this – you don’t have to worry about it, and there’s nothing for you to configure. Go’s scheduler is very good and will use all cores to the maximum efficiency as needed. (You can use the -cpu
flag to limit the number of cores Caddy uses, but this would only be useful if your site is very busy and you’re sharing CPU resources with other active processes.)
How do I test the validity of the Caddyfile before using it?
Run Caddy with the -validate
flag, and Caddy will report Caddyfile errors without executing it.
How do I update the Caddyfile while Caddy is running?
Caddy loads the Caddyfile once when it starts, and it won’t see changes to the Caddyfile unless you reload it. You can do that either by stopping and restarting the process, or on Unix systems, you can signal it with USR1 (kill -SIGUSR1
) for a graceful, zero-downtime reload.
How do I build Caddy with plugins on my own?
All you have to do is edit run.go and add an import to the plugin’s package:
import _ "your/plugin/package/path/here"
Then re-compile Caddy with ./build.bash
for proper version information to be embedded, or go build
as usual.
How do I serve PHP files with Caddy?
All you have to do is set up php-fpm like you normally do as with, say, nginx, then add something like to your Caddyfile:
fastcgi / 127.0.0.1:9000 php
This tells Caddy to proxy all requests (i.e. requests starting with /
) to 127.0.0.1:9000
via FastCGI, and using the php
preset configuration. Consult this wiki page if you have trouble.
Got other questions? Search the forum. If it hasn’t been asked before, create a new topic to ask your question!