willnorris / imageproxy

A caching, resizing image proxy written in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

imageproxy use proxy to request image?

thanh858036 opened this issue · comments

Hi Will,

First of all thanks for this wonderful tool and this is very handy, I hope if you don't mind asking can we explicitly tell imageproxy to use proxy list to request image? so that a remote site will block ip server if server request many to site

commented

Yes, you can setup proxy from Environment.
Currently, by default it uses DefaultTransport and it uses Proxy: ProxyFromEnvironment,.
You can setup it by using following tip:

func FromEnvironment() *Config {
	return &Config{
		HTTPProxy:  getEnvAny("HTTP_PROXY", "http_proxy"),
		HTTPSProxy: getEnvAny("HTTPS_PROXY", "https_proxy"),
		NoProxy:    getEnvAny("NO_PROXY", "no_proxy"),
		CGI:        os.Getenv("REQUEST_METHOD") != "",
	}
}

Thanks @Fieldistor, I wasn't even aware of that myself... that the DefaultTransport would accept those environment variables :)