func (cmd *Command) upsertHostAction(c *cli.Context) { host, err := engine.NewHost(c.String("name"), engine.HostSettings{}) if err != nil { cmd.printError(err) return } if c.String("cert") != "" || c.String("privateKey") != "" { keyPair, err := readKeyPair(c.String("cert"), c.String("privateKey")) if err != nil { cmd.printError(fmt.Errorf("failed to read key pair: %s", err)) return } host.Settings.KeyPair = keyPair } host.Settings.OCSP = engine.OCSPSettings{ Enabled: c.Bool("ocsp"), SkipSignatureCheck: c.Bool("ocspSkipCheck"), Period: c.Duration("ocspPeriod").String(), Responders: c.StringSlice("ocspResponder"), } if err := cmd.client.UpsertHost(*host); err != nil { cmd.printError(err) return } cmd.printOk("host added") }
func getFrontendSettings(c *cli.Context) (engine.HTTPFrontendSettings, error) { s := engine.HTTPFrontendSettings{} s.Limits.MaxMemBodyBytes = int64(c.Int("maxMemBodyKB") * 1024) s.Limits.MaxBodyBytes = int64(c.Int("maxBodyKB") * 1024) s.FailoverPredicate = c.String("failoverPredicate") s.Hostname = c.String("forwardHost") s.TrustForwardHeader = c.Bool("trustForwardHeader") return s, nil }
func getOptions(c *cli.Context) (backend.LocationOptions, error) { o := backend.LocationOptions{} o.Timeouts.Read = c.Duration("readTimeout").String() o.Timeouts.Dial = c.Duration("dialTimeout").String() o.Timeouts.TlsHandshake = c.Duration("handshakeTimeout").String() o.KeepAlive.Period = c.Duration("keepAlivePeriod").String() o.KeepAlive.MaxIdleConnsPerHost = c.Int("maxIdleConns") o.Limits.MaxMemBodyBytes = int64(c.Int("maxMemBodyKB") * 1024) o.Limits.MaxBodyBytes = int64(c.Int("maxBodyKB") * 1024) o.FailoverPredicate = c.String("failoverPredicate") o.Hostname = c.String("forwardHost") o.TrustForwardHeader = c.Bool("trustForwardHeader") return o, nil }
// FromCli constructs the middleware from the command line func FromCli(c *cli.Context) (plugin.Middleware, error) { opts := secure.Options{ SSLRedirect: true, SSLProxyHeaders: map[string]string{"X-Forwarded-Proto": "https"}, STSSeconds: int64(c.Int("sts-seconds")), STSPreload: c.Bool("sts-preload"), FrameDeny: c.Bool("frame-deny"), ContentTypeNosniff: c.Bool("no-sniff"), BrowserXssFilter: c.Bool("xss-filter"), ContentSecurityPolicy: c.String("content-security-policy"), } return New(opts) }
func getTLSSettings(c *cli.Context) (*engine.TLSSettings, error) { s := &engine.TLSSettings{ InsecureSkipVerify: c.Bool("tlsSkipVerify"), PreferServerCipherSuites: c.Bool("tlsPreferServerCS"), SessionTicketsDisabled: c.Bool("tlsSessionTicketsOff"), MinVersion: c.String("tlsMinV"), MaxVersion: c.String("tlsMaxV"), CipherSuites: c.StringSlice("tlsCS"), } s.SessionCache.Type = c.String("tlsSessionCache") if s.SessionCache.Type == engine.LRUCacheType { s.SessionCache.Settings = &engine.LRUSessionCacheSettings{ Capacity: c.Int("tlsSessionCacheCapacity"), } } if _, err := engine.NewTLSConfig(s); err != nil { return nil, err } return s, nil }
func FromCli(c *cli.Context) (plugin.Middleware, error) { return NewRewrite(c.String("regexp"), c.String("replacement"), c.Bool("rewriteBody"), c.Bool("redirect")) }
// FromCli constructs the middleware from the command line func FromCli(c *cli.Context) (plugin.Middleware, error) { return New(c.Bool("addHeader"), c.String("headerName")) }