Installing Imgproxy on Debian
Imgproxy is an open-source, on-the-fly image processing server. It allows you to resize and crop images on the fly to improve the performance of your website or application. In this tutorial, we will explain how to install Imgproxy on Debian.
Prerequisites
- A Debian system, with root privileges.
- An internet connection.
Step 1: Installing required dependencies
Before proceeding with the Imgproxy installation, you need to make sure that your system has all the necessary dependencies installed. You can install them using the following command:
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev pkg-config
Step 2: Downloading and Extracting Imgproxy
To download Imgproxy, use the following command:
wget https://github.com/imgproxy/imgproxy/releases/download/v2.17.1/imgproxy-linux-amd64
After downloading, extract the downloaded file using the following command:
sudo chmod +x imgproxy-linux-amd64
sudo mv imgproxy-linux-amd64 /usr/local/bin/imgproxy
Step 3: Configuring Imgproxy
Now that you have installed Imgproxy, you need to configure it. To do that, create a configuration file as follows:
sudo nano /etc/imgproxy.toml
Add the following configuration to the file:
ssl_certificate=""
ssl_private_key=""
You will also need to define the following parameters in the configuration file:
- port: The port on which Imgproxy will run. By default, Imgproxy runs on port 8080.
- key: A secret key to be used to sign image URLs.
- salt: A secret salt to be used to sign image URLs.
- origins: The domains that are allowed to access Imgproxy.
An example configuration file can be found here.
You can also configure Imgproxy to use Redis for caching. To do that, add the following configuration to the file:
cache_type="redis"
redis_url="redis://127.0.0.1:6379"
Be sure to change the Redis URL to match the configuration of your Redis instance.
Once you've finished configuring Imgproxy, save the file and exit.
Step 4: Starting Imgproxy
To start Imgproxy, use the following command:
imgproxy -config /etc/imgproxy.toml
This will start Imgproxy on port 8080 (or the port configured in your configuration file).
Step 5: Testing Imgproxy
To test that Imgproxy is working correctly, open your web browser and navigate to:
http://<your-server-ip>:8080/unsafe/100x100/path/to/image.jpg
Replace <your-server-ip> with the IP address of your server, and /path/to/image.jpg with the path to an image on your server. If Imgproxy is working correctly, you should see a 100x100 version of the image.
Conclusion
You've successfully installed and configured Imgproxy on Debian. Now, you can use Imgproxy to optimize and resize images on the fly for your website or application.