mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-30 19:55:04 -04:00
file_server: Set default address to :2015 if --listen not specified
This commit is contained in:
parent
44cb804b9e
commit
65c060f56e
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/caddyserver/caddy/v2"
|
"github.com/caddyserver/caddy/v2"
|
||||||
"github.com/caddyserver/caddy/v2/caddyconfig"
|
"github.com/caddyserver/caddy/v2/caddyconfig"
|
||||||
|
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
|
||||||
caddycmd "github.com/caddyserver/caddy/v2/cmd"
|
caddycmd "github.com/caddyserver/caddy/v2/cmd"
|
||||||
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
|
||||||
)
|
)
|
||||||
@ -81,9 +82,10 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
|
|||||||
server := &caddyhttp.Server{
|
server := &caddyhttp.Server{
|
||||||
Routes: caddyhttp.RouteList{route},
|
Routes: caddyhttp.RouteList{route},
|
||||||
}
|
}
|
||||||
if listen != "" {
|
if listen == "" {
|
||||||
server.Listen = []string{listen}
|
listen = ":" + httpcaddyfile.DefaultPort
|
||||||
}
|
}
|
||||||
|
server.Listen = []string{listen}
|
||||||
|
|
||||||
httpApp := caddyhttp.App{
|
httpApp := caddyhttp.App{
|
||||||
Servers: map[string]*caddyhttp.Server{"static": server},
|
Servers: map[string]*caddyhttp.Server{"static": server},
|
||||||
@ -100,7 +102,7 @@ func cmdFileServer(fs caddycmd.Flags) (int, error) {
|
|||||||
return caddy.ExitCodeFailedStartup, err
|
return caddy.ExitCodeFailedStartup, err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Caddy 2 serving static files")
|
log.Printf("Caddy 2 serving static files on %s", listen)
|
||||||
|
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user