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: Set default address to :2015 if --listen not specified
Matthew Holt committed
Oct 4, 2019 at 17:30 UTC
65c060f56e2e2d3a94580d938d8373f736821d83
1 file changed
+5
-3
modules/caddyhttp/fileserver/command.go
+5
-3
@@ -21,6 +21,7 @@ import (
21
22
"github.com/caddyserver/caddy/v2"
23
"github.com/caddyserver/caddy/v2/caddyconfig"
24
+ "github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
25
caddycmd "github.com/caddyserver/caddy/v2/cmd"
26
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
27
)
@@ -81,9 +82,10 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
82
server := &caddyhttp.Server{
83
Routes: caddyhttp.RouteList{route},
84
}
84
- if listen != "" {
85
- server.Listen = []string{listen}
85
+ if listen == "" {
86
+ listen = ":" + httpcaddyfile.DefaultPort
87
}
88
+ server.Listen = []string{listen}
89
90
httpApp := caddyhttp.App{
91
Servers: map[string]*caddyhttp.Server{"static": server},
@@ -100,7 +102,7 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
102
return caddy.ExitCodeFailedStartup, err
103
}
104
103
- log.Println("Caddy 2 serving static files")
105
+ log.Printf("Caddy 2 serving static files on %s", listen)
106
107
select {}
108
}