Setup a web proxy server with Docker
In this post I show you how to setup a web proxy with Docker in no time. But first of all we should ask ourselves why do we actually want to do that?
Example code: https://github.com/stefpe/squid_proxy
Why a proxy?
A proxy is sitting between a client(sending a request ) and a server(responding to the client). The proxy acts as client in front of the server
- Caching server responses
- Enforce network access policies by filtering the client requests
- Reverse proxy
- Monitoring user traffic
- Loadbalancing
- Page fragment caching via ESI (e.g. Symfony framework)
- Deploy a traffic proxy in another country/region to unblock foreign checks
- ….
As you can see a proxy offers a lot of possibilities to improve the performance and exprience of your application setup and makes your daily dev life easier.
Let’s run a proxy — Squid (old but gold)
We take it easy and use a squid proxy image ready to lift off. Squid is also easy to install on ubuntu with a simple apt install squid. So here’s the docker-compose.yml to setup the proxy: