diff --git a/home/config.go b/home/config.go index dfcc6842..5590715e 100644 --- a/home/config.go +++ b/home/config.go @@ -51,6 +51,7 @@ type configuration struct { BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server Users []User `yaml:"users"` // Users that can access HTTP server + ProxyURL string `yaml:"http_proxy"` // Proxy address for our HTTP client Language string `yaml:"language"` // two-letter ISO 639-1 language code RlimitNoFile uint `yaml:"rlimit_nofile"` // Maximum number of opened fd's per process (0: default) diff --git a/home/home.go b/home/home.go index f7c697f6..4661cd13 100644 --- a/home/home.go +++ b/home/home.go @@ -9,6 +9,7 @@ import ( "io/ioutil" "net" "net/http" + "net/url" "os" "os/exec" "os/signal" @@ -137,6 +138,7 @@ func run(args options) { // Init some of the Context fields right away Context.transport = &http.Transport{ DialContext: customDialContext, + Proxy: getHTTPProxy, } Context.client = &http.Client{ Timeout: time.Minute * 5, @@ -658,3 +660,10 @@ func customDialContext(ctx context.Context, network, addr string) (net.Conn, err } return nil, errorx.DecorateMany(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...) } + +func getHTTPProxy(req *http.Request) (*url.URL, error) { + if len(config.ProxyURL) == 0 { + return nil, nil + } + return url.Parse(config.ProxyURL) +}