Custom template for "No such site at {}"

How i can use custom error template for “No such site at :80” (404) when i use DNS wildcard which resolves all name to Caddy server?

Version 0.10.5 will have some basic groundwork making this possible, but for now and even then you’ll have to compile your own version of Caddy to use it…

Actually the correct way is not to change that text, but rather to define a wildcard host in your Caddyfile. This will cause all non-marching requests to be handled in the way defined by your Caddyfile.

https://, http:// {
   # how to handle unmatched sites

Rough used Caddyfile with Caddy (untracked dev build) from master

# All imported http/https hosts
import /etc/caddy/vhosts/*

https://host1.domain {

https://host2.domain {
http://, https:// {
  root /etc/caddy/static
  log / stdout "{combined} {latency}"
  errors stdout {
    404 error/404.html

Unfortunately, this works only for http. When combined with https Caddy can’t reload configuration with error

2017/07/29 11:40:23 [ERROR] SIGUSR1: cannot multiplex host2.domain (TLS) and  (not TLS) on same listener

Ah, so I was giving a rough example to demonstrate the idea. If you specify a wildcard/catchall https:// site like that, you have to either enable on-demand TLS (which will fail for sites you don’t host anyway) with max_certs, because remember the requirements for automatic HTTPS to be enabled - or provide your own certificate of some sort.

Handling “No such site” errors for HTTPS isn’t usually useful unless you have a specific need to do it, so you can remove the https:// definition and just do it for plain HTTP.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.