A proxy server is a system or router that provides a gateway between users and the internet. Therefore, it helps prevent cyber attackers from entering a private network. It is a server, referred to as an "intermediary" because it goes between end-users and the web pages they visit online.
This server is designed to block websites defined in a text file. We will use Axum's http-proxy example and add the feature to block the websites.
- ✅ HTTP/HTTPS proxy functionality
- ✅ Website blocking via configuration file
- ✅ Built with Rust and Axum framework
- ✅ Docker support for easy deployment
- ✅ High performance and low resource usage
- Build the image
docker build -t proxy .- Run the container
docker run -p 8080:8080 -d proxy- Pull the pre-built image
docker pull ghcr.io/imrany/proxy:latest- Run the container
docker run -p 8080:8080 -d ghcr.io/imrany/proxy- Prerequisites
- Rust 1.70+ installed
- Cargo package manager
- Clone and run
git clone https://github.com/imrany/proxy-server.git
cd proxy-server
cargo runOnce the server is running, test it with curl:
# Test HTTP request through proxy
curl -v -x "127.0.0.1:8080" http://httpbin.org/ip
# Test HTTPS request through proxy
curl -v -x "127.0.0.1:8080" https://tokio.rsChrome/Edge:
Settings → Advanced → System → Open proxy settings
HTTP Proxy: 127.0.0.1:8080
HTTPS Proxy: 127.0.0.1:8080
Firefox:
Settings → Network Settings → Manual proxy configuration
HTTP Proxy: 127.0.0.1 Port: 8080
Use this proxy server for all protocols: ✓
Create a blocked_sites.txt file in the project root:
www.instagram.com:443
twitter.com:443
discord.com:443
The proxy will block access to any domains listed in this file.
| Variable | Default | Description |
|---|---|---|
PROXY_PORT |
8080 |
Port to run the proxy server |
BLOCKED_SITES_FILE |
blocked_sites.txt |
Path to blocked sites configuration |
LOG_LEVEL |
info |
Logging level (debug, info, warn, error) |
docker run -p 8080:8080 -d \
-e PROXY_PORT=8080 \
-e LOG_LEVEL=debug \
-v $(pwd)/blocked_sites.txt:/app/blocked_sites.txt \
ghcr.io/imrany/proxy# Debug build
cargo build
# Release build
cargo build --release
# Run tests
cargo test# Build development image
docker build -t proxy:dev .
# Run with volume mounting for development
docker run -p 8080:8080 -v $(pwd):/app proxy:dev- Memory Usage: ~10MB base
- Concurrent Connections: 1000+
- Latency Overhead: <5ms
- Throughput: Limited by network bandwidth
The proxy logs all requests and blocked attempts:
2025-06-29T11:34:48.243347Z DEBUG proxy: listening on 0.0.0.0:8080
2025-06-29T11:36:30.369691Z TRACE proxy: req=Request { method: CONNECT, uri: tokio.rs:443, version: HTTP/1.1, headers: {"host": "tokio.rs:443", "user-agent": "curl/8.5.0", "proxy-connection": "Keep-Alive"}, body: Body(UnsyncBoxBody) }
- Corporate Networks: Block social media and non-work sites
- Parental Controls: Restrict access to inappropriate content
- Development Testing: Intercept and analyze HTTP traffic
- Privacy Protection: Mask client IP addresses
- Load Testing: Simulate different network conditions
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Port already in use:
# Find process using port 8080
lsof -i :8080
# Kill the process
kill -9 <PID>Permission denied (Linux):
# Run with sudo if binding to port < 1024
sudo docker run -p 80:8080 proxyBlocked sites not working:
- Ensure
blocked_sites.txtexists and is readable - Check file format (one domain per line)
- Verify domain names don't include protocols (http://)
# View all connections
curl http://127.0.0.1:8080/api/connections
# View user statistics
curl http://127.0.0.1:8080/api/stats
# View active connections
curl http://127.0.0.1:8080/api/active- 📧 Email: imranmat254@gmail.com
- Sponsor me: Github Sponsors
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
