iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
😎

Caddy: 'input is not formatted' warning when using space indentation in Caddyfile

に公開

Operating Environment

  • XUbuntu 18.04
  • caddy v2.4.5

Introduction

I am using a web server called Caddy.

When I started caddy using the following Caddyfile, a warning appeared: input is not formatted with 'caddy fmt'.

Caddyfile
localhost {
    file_server browse
}
$ ls
Caddyfile  hello.txt

$ sudo caddy run -config Caddyfile 
2021/09/19 23:46:39.326	INFO	using provided configuration	{"config_file": "Caddyfile", "config_adapter": ""}
2021/09/19 23:46:39.326	WARN	input is not formatted with 'caddy fmt'	{"adapter": "caddyfile", "file": "Caddyfile", "line": 2}
2021/09/19 23:46:39.327	INFO	admin	admin endpoint started	{"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/09/19 23:46:39.327	INFO	http	server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS	{"server_name": "srv0", "https_port": 443}
2021/09/19 23:46:39.327	INFO	http	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv0"}
2021/09/19 23:46:39.329	INFO	tls	cleaning storage unit	{"description": "FileStorage:/home/vagrant/.local/share/caddy"}
2021/09/19 23:46:39.329	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0xc000378d20"}
2021/09/19 23:46:39.329	INFO	tls	finished cleaning storage units
2021/09/19 23:46:39.345	INFO	pki.ca.local	root certificate is already trusted by system	{"path": "storage:pki/authorities/local/root.crt"}
2021/09/19 23:46:39.345	INFO	http	enabling automatic TLS certificate management	{"domains": ["localhost"]}
2021/09/19 23:46:39.345	WARN	tls	stapling OCSP	{"error": "no OCSP stapling for [localhost]: no OCSP server specified in certificate"}
2021/09/19 23:46:39.346	INFO	autosaved config (load with --resume flag)	{"file": "/home/vagrant/.config/caddy/autosave.json"}
2021/09/19 23:46:39.346	INFO	serving initial configuration

Cause of the Warning

The Caddyfile needed to be formatted using the caddy fmt command.

$ caddy fmt -overwrite Caddyfile

When the Caddyfile is formatted, it becomes the following:

Caddyfile
localhost {
	file_server browse
}

The indentation was converted from spaces to tabs.
Apparently, tabs are the recommended indentation style.

References

GitHubで編集を提案

Discussion