diff --git a/caddy/caddy.go b/caddy/caddy.go index 839bdae0..ba5a79be 100644 --- a/caddy/caddy.go +++ b/caddy/caddy.go @@ -282,15 +282,7 @@ func LoadCaddyfile(loader func() (Input, error)) (cdyfile Input, err error) { cdyfile = loadedGob.Caddyfile } - // Otherwise, we first try to get from stdin pipe - if cdyfile == nil { - cdyfile, err = CaddyfileFromPipe(os.Stdin) - if err != nil { - return nil, err - } - } - - // No piped input, so try the user's loader instead + // Try user's loader if cdyfile == nil && loader != nil { cdyfile, err = loader() } diff --git a/main.go b/main.go index 818fef71..e7e4608e 100644 --- a/main.go +++ b/main.go @@ -117,6 +117,19 @@ func mustLogFatal(args ...interface{}) { } func loadCaddyfile() (caddy.Input, error) { + // First try stdin pipe + cdyfile, err := caddy.CaddyfileFromPipe(os.Stdin) + if err != nil { + return nil, err + } + if cdyfile != nil { + // it is an error if -conf is also specified because, which to use? + if conf != "" { + return nil, errors.New("load: can't choose between stdin pipe and -conf flag") + } + return cdyfile, err + } + // -conf flag if conf != "" { contents, err := ioutil.ReadFile(conf)