Caddy (web server): Difference between revisions

No edit summary
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
* [https://caddyserver.com/ Website]
* [https://caddyserver.com/ Website]


Caddy is a webserver which is much simpler to configure than Apache and is supposedly just as fast as nginx.
Caddy is a webserver with automatic HTTPS and modern defaults (e.g. http2, websocket support).
It handles HTTPS automatically and can be used as a reverse proxy or load balancer.
 
Advantages of Caddy:
* Much simpler configuration with sane defaults (e.g. no directory listing).
* Automatic HTTPS (redirect, public certificates, self-signed certificates)
* Automatic HTTP/2
 
This article is about Caddy v2.
This article is about Caddy v2.
Note that caddy does not support <code>.htaccess</code> which is only supported in Apache.
Note that caddy does not support <code>.htaccess</code> which is only supported in Apache.


Line 40: Line 32:


* Try this if you get <code>502</code> errors.
* Try this if you get <code>502</code> errors.
===Only Local===
<pre>
  @localnet remote_ip 127.0.0.1 192.168.0.0/16
  @notlocalnet not remote_ip 127.0.0.1 192.168.0.0/16
</pre>


==PHP==
==PHP==
# Install <code>php-fpm</code>
# Install <code>php-fpm</code>
# Modify <code>/etc/php/7.4/fpm/pool.d/www.conf</code> to listen on a socket (e.g. 9000)
# Modify <code>/etc/php/7.4/fpm/pool.d/www.conf</code> to listen on a socket or port (e.g. 9000)
<pre>
<pre>
example.com {
example.com {
Line 56: Line 54:
* If you prefer to use a UNIX socket, you can use <code>php_fastcgi unix//var/run/php/php7.4-fpm.sock</code>
* If you prefer to use a UNIX socket, you can use <code>php_fastcgi unix//var/run/php/php7.4-fpm.sock</code>


===HTTP3===
==HTTP3==
Add the following to your Caddyfile:
Experimental HTTP3 support can be enabled by adding the following to your Caddyfile.<br>
Note that HTTP3/QUIC uses UDP which needs to be allowed in your firewall and port forwarded through any NATs.<br>
<pre>
<pre>
{  
{