A Caddy module for QUIC-only listeners.
This module allows you to configure Caddy to only accept QUIC connections (HTTP/3) or only TCP connections (HTTP/1.1, HTTP/2), rather than both.
By default, Caddy will bind to both TCP and UDP ports when configured for HTTPS, with TCP handling HTTP/1.1 and HTTP/2, and UDP handling HTTP/3 (QUIC). This module allows you to restrict Caddy to only listen on one protocol or the other.
- Caddy v2
xcaddy build --with github.com/aUsernameWoW/caddy-quic-only=.{
servers {
listener_wrappers {
quic_only {
mode quic_only
}
tls
}
}
}
:8443 {
respond "Hello, QUIC-only world!" 200
}
{
servers {
listener_wrappers {
quic_only {
mode tcp_only
}
tls
}
}
}
:8443 {
respond "Hello, TCP-only world!" 200
}
{
"apps": {
"http": {
"servers": {
"example": {
"listen": [":8443"],
"listener_wrappers": [
{
"wrapper": "quic_only",
"mode": "quic_only"
},
{
"wrapper": "tls"
}
],
"routes": [
{
"handle": [
{
"handler": "static_response",
"body": "Hello, QUIC-only world!",
"status_code": 200
}
]
}
]
}
}
}
}
}{
"apps": {
"http": {
"servers": {
"example": {
"listen": [":8443"],
"listener_wrappers": [
{
"wrapper": "quic_only",
"mode": "tcp_only"
},
{
"wrapper": "tls"
}
],
"routes": [
{
"handle": [
{
"handler": "static_response",
"body": "Hello, TCP-only world!",
"status_code": 200
}
]
}
]
}
}
}
}
}quic_only- Only allow QUIC (HTTP/3) connectionstcp_only- Only allow TCP (HTTP/1.1, HTTP/2) connectionsdefault- Allow both QUIC and TCP connections (default behavior)
This module implements the caddy.ListenerWrapper interface, but the actual protocol filtering is done by modifying the server's protocol configuration. The listener wrapper is kept for consistency with the ListenerWrapper interface, but the real work is done in the server's protocol configuration:
- In
quic_onlymode, only HTTP/3 (h3) is enabled - In
tcp_onlymode, only HTTP/1.1 (h1) and HTTP/2 (h2) are enabled - In
defaultmode, all protocols are enabled as configured by the server
This approach provides a more complete solution than just wrapping listeners, as it prevents Caddy from even attempting to create listeners for protocols that are not wanted.
MIT