Skip to content
Permalink
Browse files

IMGPROXY_NETWORK config

  • Loading branch information
DarthSim committed Feb 3, 2020
1 parent 6db5b8e commit 45306adc23f9afc29e21c8435e34d9e1bd5297a4
Showing with 10 additions and 3 deletions.
  1. +3 −0 CHANGELOG.md
  2. +3 −0 config.go
  3. +3 −2 docs/configuration.md
  4. +1 −1 server.go
@@ -1,6 +1,9 @@
# Changelog

## [Unreleased]
### Added
- `IMGPROXY_NETWORK` config. Allows to bind on Unix socket.

### Fixed
- Fix detection of SVG starting with a comment.

@@ -145,6 +145,7 @@ func presetFileConfig(p presets, filepath string) {
}

type config struct {
Network string
Bind string
ReadTimeout int
WriteTimeout int
@@ -231,6 +232,7 @@ type config struct {
}

var conf = config{
Network: "tcp",
Bind: ":8080",
ReadTimeout: 10,
WriteTimeout: 10,
@@ -272,6 +274,7 @@ func configure() {
conf.Bind = fmt.Sprintf(":%s", port)
}

strEnvConfig(&conf.Network, "IMGPROXY_NETWORK")
strEnvConfig(&conf.Bind, "IMGPROXY_BIND")
intEnvConfig(&conf.ReadTimeout, "IMGPROXY_READ_TIMEOUT")
intEnvConfig(&conf.WriteTimeout, "IMGPROXY_WRITE_TIMEOUT")
@@ -26,7 +26,8 @@ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')

## Server

* `IMGPROXY_BIND`: TCP address and port to listen on. Default: `:8080`;
* `IMGPROXY_BIND`: address and port or Unix socket to listen on. Default: `:8080`;
* `IMGPROXY_NETWORK`: network to use. Known networks are `tcp`, `tcp4`, `tcp6`, `unix`, and `unixpacket`. Default: `tcp`;
* `IMGPROXY_READ_TIMEOUT`: the maximum duration (in seconds) for reading the entire image request, including the body. Default: `10`;
* `IMGPROXY_WRITE_TIMEOUT`: the maximum duration (in seconds) for writing the response. Default: `10`;
* `IMGPROXY_KEEP_ALIVE_TIMEOUT`: the maximum duration (in seconds) to wait for the next request before closing the connection. When set to `0`, keep-alive is disabled. Default: `10`;
@@ -253,4 +254,4 @@ imgproxy can send logs to syslog, but this feature is disabled by default. To en
* `IMGPROXY_USE_LINEAR_COLORSPACE`: when `true`, imgproxy will process images in linear colorspace. This will slow down processing. Note that images won't be fully processed in linear colorspace while shrink-on-load is enabled (see below).
* `IMGPROXY_DISABLE_SHRINK_ON_LOAD`: when `true`, disables shrink-on-load for JPEG and WebP. Allows to process the whole image in linear colorspace but dramatically slows down resizing and increases memory usage when working with large images.
* `IMGPROXY_APPLY_UNSHARPEN_MASKING`: <img class="pro-badge" src="assets/pro.svg" alt="pro" /> when `true`, imgproxy will apply unsharpen masking to the resulting image if one is smaller than the source. Default: `true`.
* `IMGPROXY_STRIP_METADATA`: whether to strip all metadata (EXIF, IPTC, etc.) from JPEG and WebP output images. Default: `true`.
* `IMGPROXY_STRIP_METADATA`: whether to strip all metadata (EXIF, IPTC, etc.) from JPEG and WebP output images. Default: `true`.
@@ -32,7 +32,7 @@ func buildRouter() *router {
}

func startServer() *http.Server {
l, err := listenReuseport("tcp", conf.Bind)
l, err := listenReuseport(conf.Network, conf.Bind)
if err != nil {
logFatal(err.Error())
}

0 comments on commit 45306ad

Please sign in to comment.
You can’t perform that action at this time.