Imgproxy is a standalone server for resizing images. It is optional and you do not need it to start Forem locally. We are currently only using it in Forem Cloud.
- MacOS: install via homebrew with
brew install imgproxy.
- Windows: please install via docker.
- Linux: you can either use docker installation or build from source.
For more options not covered here, please take a look at the official installation documentation.
Generate a key/salt pair by running the following in your terminal twice. Copy those values to your
.envin the next step
echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n')
.env, add the following.
export IMGPROXY_ENDPOINT='http://localhost:8080'export IMGPROXY_KEY='1b1c9aae804e070b0864f2547fba7ce8ff31bf7..........'export IMGPROXY_SALT='8c6d449d4fc2cada5bab538826cae709d2ade9f.........'
Start the Forem app server normally.
Start Imgproxy in a terminal with the key and salt.
# If you installed via homebrew or using the binary.> IMGPROXY_KEY='your key' IMGPROXY_SALT='your salt' imgproxy # If you are using Docker or Podman. The commands are identical for both> docker run -p 8080:8080 \ -e IMGPROXY_KEY="your key" \ -e IMGPROXY_SALT="your salt" \ -it darthsim/imgproxy
That's it :)
You should verify it's working by starting the Forem app locally and see that each image is loaded properly, or run the following command while the Forem app is running:
> curl -I http://localhost:8080/unsafe/aHR0cDovL2xvY2Fs/aG9zdDozMDAwL2Fz/c2V0cy8xLnBuZw HTTP/1.1 200 OKServer: imgproxyX-Request-Id: GYvCGXb98JUwL3ujwpjzhDate: Tue, 27 Oct 2020 16:11:37 GMT
- Because Imgproxy is a standalone server of its own, all image URLs given to it need to be absolute URLs.
- When working with Docker or Podman on Linux, provide the host network option
--network="host") so Imgproxy can properly access the localhost.