Переглянути джерело

IMGPROXY_HEALTH_CHECK_PATH config

DarthSim 3 роки тому
батько
коміт
df818706c2
4 змінених файлів з 12 додано та 1 видалено
  1. 1 0
      CHANGELOG.md
  2. 6 0
      config/config.go
  3. 2 1
      docs/configuration.md
  4. 3 0
      server.go

+ 1 - 0
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

+ 6 - 0
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
 	}

+ 2 - 1
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`: <i class='badge badge-pro'></i> the content of the `/health` response. Default: `imgproxy is running`
+* `IMGPROXY_HEALTH_CHECK_MESSAGE`: <i class='badge badge-pro'></i> the content of the health check response. Default: `imgproxy is running`
+* `IMGPROXY_HEALTH_CHECK_PATH`: an additional path of the health check. Default: blank

+ 3 - 0
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)