@marcel91200 / caddy Mirror · read-only / commits / 788462bd
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

file-server command: Use safer defaults; http: improve host matcher docs

Matthew Holt committed Dec 31, 2019 at 16:57 UTC 788462bd4c9c332b3f892094b1d17147378f5e6a
2 files changed +16 -2
modules/caddyhttp/fileserver/command.go
+6 -2
@@ -19,6 +19,7 @@ import (
19 "flag"
20 "log"
21 "strconv"
22 + "time"
23
24 "github.com/caddyserver/caddy/v2"
25 "github.com/caddyserver/caddy/v2/caddyconfig"
@@ -32,7 +33,7 @@ func init() {
33 caddycmd.RegisterCommand(caddycmd.Command{
34 Name: "file-server",
35 Func: cmdFileServer,
35 - Usage: "[--domain <example.com>] [--path <path>] [--listen <addr>] [--browse]",
36 + Usage: "[--domain <example.com>] [--root <path>] [--listen <addr>] [--browse]",
37 Short: "Spins up a production-ready file server",
38 Long: `
39 A simple but production-ready file server. Useful for quick deployments,
@@ -83,7 +84,10 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
84 }
85
86 server := &caddyhttp.Server{
86 - Routes: caddyhttp.RouteList{route},
87 + ReadHeaderTimeout: caddy.Duration(10 * time.Second),
88 + IdleTimeout: caddy.Duration(30 * time.Second),
89 + MaxHeaderBytes: 1024 * 10,
90 + Routes: caddyhttp.RouteList{route},
91 }
92 if listen == "" {
93 if certmagic.HostQualifies(domain) {
modules/caddyhttp/matchers.go
+10
@@ -34,6 +34,16 @@ import (
34
35 type (
36 // MatchHost matches requests by the Host value (case-insensitive).
37 + //
38 + // When used in an HTTP route,
39 + // [qualifying domain names](/docs/automatic-https#hostname-requirements)
40 + // may trigger [automatic HTTPS](/docs/automatic-https), which automatically
41 + // provisions and renews certificates for you. Before doing this, you
42 + // should ensure that DNS records for these domains are properly configured,
43 + // especially A/AAAA pointed at your server.
44 + //
45 + // Automatic HTTPS can be
46 + // [customized or disabled](/docs/json/apps/http/servers/automatic_https/).
47 MatchHost []string
48
49 // MatchPath matches requests by the URI's path (case-insensitive).