Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make insecure upstream servers configurable #1007

Merged
merged 3 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/proxy-allow-insecure-upstreams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Change: Proxy allow insecure upstreams

Tags: proxy

We can now configure the proxy if insecure upstream servers are allowed.
This was added since you need to disable certificate checks fore some situations like testing.

https://github.com/owncloud/ocis/pull/1007
1 change: 1 addition & 0 deletions proxy/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type Config struct {
PreSignedURL PreSignedURL
AutoprovisionAccounts bool
EnableBasicAuth bool
InsecureBackends bool
}

// OIDC is the config for the OpenID-Connect middleware. If set the proxy will try to authenticate every request
Expand Down
7 changes: 7 additions & 0 deletions proxy/pkg/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"PROXY_REVA_GATEWAY_ADDR"},
Destination: &cfg.Reva.Address,
},
&cli.BoolFlag{
Name: "insecure",
Value: false,
Usage: "allow insecure communication to upstream servers",
EnvVars: []string{"PROXY_INSECURE_BACKENDS"},
Destination: &cfg.InsecureBackends,
},

// OIDC

Expand Down
21 changes: 21 additions & 0 deletions proxy/pkg/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package proxy

import (
"context"
"crypto/tls"
"net"
"net/http"
"net/http/httputil"
"net/url"
"regexp"
"strings"
"time"

"github.com/owncloud/ocis/proxy/pkg/proxy/policy"
"go.opencensus.io/plugin/ochttp/propagation/tracecontext"
Expand Down Expand Up @@ -37,6 +40,24 @@ func NewMultiHostReverseProxy(opts ...Option) *MultiHostReverseProxy {
}
rp.Director = rp.directorSelectionDirector

// equals http.DefaultTransport except TLSClientConfig
rp.Transport = &http.Transport{
wkloucek marked this conversation as resolved.
Show resolved Hide resolved
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: options.Config.InsecureBackends,
},
}

if options.Config.Policies == nil {
rp.logger.Info().Str("source", "runtime").Msg("Policies")
options.Config.Policies = defaultPolicies()
Expand Down