1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-03-22 20:21:28 +02:00

Sending User-Agent with source image request

This commit is contained in:
DarthSim 2018-10-30 19:37:41 +06:00
parent c043716ac1
commit ea10cbe059
3 changed files with 14 additions and 1 deletions

View File

@ -140,6 +140,8 @@ type config struct {
AllowOrigin string
UserAgent string
IgnoreSslVerification bool
LocalFileSystemRoot string
@ -176,6 +178,7 @@ var conf = config{
AllowInsecure: false,
Quality: 80,
GZipCompression: 5,
UserAgent: fmt.Sprintf("imgproxy/%s", version),
ETagEnabled: false,
S3Enabled: false,
WatermarkOpacity: 1,
@ -227,6 +230,8 @@ func init() {
strEnvConfig(&conf.AllowOrigin, "IMGPROXY_ALLOW_ORIGIN")
strEnvConfig(&conf.UserAgent, "IMGPROXY_USER_AGENT")
boolEnvConfig(&conf.IgnoreSslVerification, "IMGPROXY_IGNORE_SSL_VERIFICATION")
strEnvConfig(&conf.LocalFileSystemRoot, "IMGPROXY_LOCAL_FILESYSTEM_ROOT")

View File

@ -30,6 +30,7 @@ $ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
* `IMGPROXY_CONCURRENCY`: the maximum number of image requests to be processed simultaneously. Default: number of CPU cores times two;
* `IMGPROXY_MAX_CLIENTS`: the maximum number of simultaneous active connections. Default: `IMGPROXY_CONCURRENCY * 10`;
* `IMGPROXY_TTL`: duration (in seconds) sent in `Expires` and `Cache-Control: max-age` HTTP headers. Default: `3600` (1 hour);
* `IMGPROXY_USER_AGENT`: User-Agent header that will be sent with source image request. Default: `imgproxy/%current_version`;
* `IMGPROXY_USE_ETAG`: when `true`, enables using [ETag](https://en.wikipedia.org/wiki/HTTP_ETag) HTTP header for HTTP cache control. Default: false;
### Security

View File

@ -149,7 +149,14 @@ func downloadImage(ctx context.Context) (context.Context, context.CancelFunc, er
defer startPrometheusDuration(prometheusDownloadDuration)()
}
res, err := downloadClient.Get(url)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return ctx, func() {}, err
}
req.Header.Set("User-Agent", conf.UserAgent)
res, err := downloadClient.Do(req)
if err != nil {
return ctx, func() {}, err
}