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

Add IMGPROXY_ENABLE_DEBUG_HEADERS config for debugging infomation (#509)

This commit is contained in:
Huy Le Viet 2020-11-20 11:52:16 +07:00 committed by GitHub
parent cee746a1ee
commit a62b22af69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -267,6 +267,8 @@ type config struct {
ReportDownloadingErrors bool
EnableDebugHeaders bool
FreeMemoryInterval int
DownloadBufferSize int
GZipBufferSize int
@ -430,6 +432,7 @@ func configure() error {
strEnvConfig(&conf.SentryEnvironment, "IMGPROXY_SENTRY_ENVIRONMENT")
strEnvConfig(&conf.SentryRelease, "IMGPROXY_SENTRY_RELEASE")
boolEnvConfig(&conf.ReportDownloadingErrors, "IMGPROXY_REPORT_DOWNLOADING_ERRORS")
boolEnvConfig(&conf.EnableDebugHeaders, "IMGPROXY_ENABLE_DEBUG_HEADERS")
intEnvConfig(&conf.FreeMemoryInterval, "IMGPROXY_FREE_MEMORY_INTERVAL")
intEnvConfig(&conf.DownloadBufferSize, "IMGPROXY_DOWNLOAD_BUFFER_SIZE")

View File

@ -43,6 +43,7 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
* `IMGPROXY_CUSTOM_REQUEST_HEADERS`: <img class='pro-badge' src='assets/pro.svg' alt='pro' /> list of custom headers that imgproxy will send while requesting the source image, divided by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`;
* `IMGPROXY_CUSTOM_RESPONSE_HEADERS`: <img class='pro-badge' src='assets/pro.svg' alt='pro' /> list of custom response headers, divided by `\;` (can be redefined by `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`). Example: `X-MyHeader1=Lorem\;X-MyHeader2=Ipsum`;
* `IMGPROXY_CUSTOM_HEADERS_SEPARATOR`: <img class='pro-badge' src='assets/pro.svg' alt='pro' /> string that will be used as a custom headers separator. Default: `\;`;
* `IMGPROXY_ENABLE_DEBUG_HEADERS`: when `true`, imgproxy will add `X-Origin-Content-Length` header with the value is size of the source image. Default: `false`.
## Security

View File

@ -111,6 +111,11 @@ func respondWithImage(ctx context.Context, reqID string, r *http.Request, rw htt
rw.Write(data)
}
if conf.EnableDebugHeaders {
imgdata := getImageData(ctx)
rw.Header().Set("X-Origin-Content-Length", strconv.Itoa(len(imgdata.Data)))
}
imageURL := getImageURL(ctx)
logResponse(reqID, r, 200, nil, &imageURL, po)