From df818706c25492884a040d6bcc19379b1f3dc320 Mon Sep 17 00:00:00 2001 From: DarthSim Date: Mon, 21 Feb 2022 18:06:20 +0600 Subject: [PATCH] IMGPROXY_HEALTH_CHECK_PATH config --- CHANGELOG.md | 1 + config/config.go | 6 ++++++ docs/configuration.md | 3 ++- server.go | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd92d07c..e344d845 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - Add the `IMGPROXY_MAX_REDIRECTS` config. - (pro) Add the `IMGPROXY_SERVER_NAME` config. - (pro) Add the `IMGPROXY_HEALTH_CHECK_MESSAGE` config. +- Add the `IMGPROXY_HEALTH_CHECK_PATH` config. ## [3.2.2] - 2022-02-08 ### Fix diff --git a/config/config.go b/config/config.go index 83d5af37..10ab4337 100644 --- a/config/config.go +++ b/config/config.go @@ -137,6 +137,8 @@ var ( FreeMemoryInterval int DownloadBufferSize int BufferPoolCalibrationThreshold int + + HealthCheckPath string ) var ( @@ -275,6 +277,8 @@ func Reset() { FreeMemoryInterval = 10 DownloadBufferSize = 0 BufferPoolCalibrationThreshold = 1024 + + HealthCheckPath = "" } func Configure() error { @@ -328,6 +332,8 @@ func Configure() error { configurators.Bool(&EnforceAvif, "IMGPROXY_ENFORCE_AVIF") configurators.Bool(&EnableClientHints, "IMGPROXY_ENABLE_CLIENT_HINTS") + configurators.String(&HealthCheckPath, "IMGPROXY_HEALTH_CHECK_PATH") + if err := configurators.ImageTypes(&SkipProcessingFormats, "IMGPROXY_SKIP_PROCESSING_FORMATS"); err != nil { return err } diff --git a/docs/configuration.md b/docs/configuration.md index ebed243b..e6f152e4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -401,4 +401,5 @@ imgproxy can send logs to syslog, but this feature is disabled by default. To en * `IMGPROXY_STRIP_METADATA`: when `true`, imgproxy will strip all metadata (EXIF, IPTC, etc.) from JPEG and WebP output images. Default: `true` * `IMGPROXY_STRIP_COLOR_PROFILE`: when `true`, imgproxy will transform the embedded color profile (ICC) to sRGB and remove it from the image. Otherwise, imgproxy will try to keep it as is. Default: `true` * `IMGPROXY_AUTO_ROTATE`: when `true`, imgproxy will automatically rotate images based on the EXIF Orientation parameter (if available in the image meta data). The orientation tag will be removed from the image in all cases. Default: `true` -* `IMGPROXY_HEALTH_CHECK_MESSAGE`: the content of the `/health` response. Default: `imgproxy is running` +* `IMGPROXY_HEALTH_CHECK_MESSAGE`: the content of the health check response. Default: `imgproxy is running` +* `IMGPROXY_HEALTH_CHECK_PATH`: an additional path of the health check. Default: blank diff --git a/server.go b/server.go index 6b242a67..15879597 100644 --- a/server.go +++ b/server.go @@ -29,6 +29,9 @@ func buildRouter() *router.Router { r.GET("/", handleLanding, true) r.GET("/health", handleHealth, true) + if len(config.HealthCheckPath) > 0 { + r.GET(config.HealthCheckPath, handleHealth, true) + } r.GET("/favicon.ico", handleFavicon, true) r.GET("/", withMetrics(withPanicHandler(withCORS(withSecret(handleProcessing)))), false) r.HEAD("/", withCORS(handleHead), false)