Commit 1e730a74 authored by Matt Holt's avatar Matt Holt

Merge pull request #50 from ChannelMeter/core/bind_address

core: Add the option to specify what address to bind on in Caddyfile
parents 4637f14b 46f79307
......@@ -43,6 +43,7 @@ var directiveOrder = []directive{
// Essential directives that initialize vital configuration settings
{"root", setup.Root},
{"tls", setup.TLS},
{"bind", setup.BindHost},
// Other directives that don't create HTTP handlers
{"startup", setup.Startup},
......
package setup
import "github.com/mholt/caddy/middleware"
func BindHost(c *Controller) (middleware.Middleware, error) {
for c.Next() {
if !c.Args(&c.BindHost) {
return nil, c.ArgErr()
}
}
return nil, nil
}
......@@ -11,6 +11,9 @@ type Config struct {
// The hostname or IP on which to serve
Host string
// The host address to bind on - defaults to (virtual) Host if empty
BindHost string
// The port to listen on
Port string
......@@ -44,6 +47,9 @@ type Config struct {
// Address returns the host:port of c as a string.
func (c Config) Address() string {
if c.BindHost != "" {
return net.JoinHostPort(c.BindHost, c.Port)
}
return net.JoinHostPort(c.Host, c.Port)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment