webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.
https://docs.webp.sh
GNU General Public License v3.0
1.79k stars 174 forks source link

Pass "IMG_PATH" as a dynamic value to support multiple folders and websites #219

Closed pixiemediaweb closed 1 year ago

pixiemediaweb commented 1 year ago

It would be great to be able to pass the IMG_PATH variable from nginx to the config so we can support multiple folders and websites from a single implementation.

For example something like this;

location ^~ /media/resized/ { location ~* .(jpg|jpeg|png|gif)$ {
expires 30d; proxy_pass http://127.0.0.1:3333; set $IMAGE_PATH '/var/www/folder', proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; proxy_set_header Host $host; proxy_read_timeout 3600; }

}

Which would then be picked up by the config.json something like this;

{ "HOST": "127.0.0.1", "PORT": "3333", "QUALITY": "80", "IMG_PATH": $IMAGE_PATH, "EXHAUST_PATH": "/var/www/webpcache", "ALLOWED_TYPES": ["jpg","png","jpeg","bmp","gif"], "ENABLE_AVIF": false }

n0vad3v commented 1 year ago

For supporting multiple folders and websites, we have a discussion at https://github.com/webp-sh/webp_server_go/issues/217, we can discuss there.

n0vad3v commented 1 year ago

Closing this PR now as we've Multipath feature starting from version 0.9.9, docs: https://docs.webp.sh/usage/multipath/.