This project provides a PAC (Proxy Auto-Configuration) server that helps manage proxy settings for your network traffic.
- Dynamic proxy configuration based on URL patterns
- Support for both Docker and non-Docker deployments
- Simple and lightweight implementation
- Python 3.x
- Docker (optional, for containerized deployment)
git clone https://github.com/MrMontazer/pac-server.git
cd pac-serverpip install -r requirements.txt
python main.pyThe server will start on port 80 by default.
Build and run using Docker Compose:
docker compose up -dOr build and run using Docker directly:
docker build -t pac-server .
docker run -d -p 80:80 pac-serverYou can customize the proxy behavior by modifying the config.yml file. The configuration file allows you to:
- Define multiple proxy servers (HTTP, HTTPS, SOCKS5)
- Set direct access rules for specific domains/IPs
- Configure proxy rules for specific domains
- Set fallback behavior
You can configure multiple proxies by adding them to the proxy section. The PAC server will use them in a round-robin fashion for load balancing.
Example config.yml:
proxy:
- "http 1.1.1.1:1080" # HTTP proxy
# - "http 2.2.2.2:1080" # Second HTTP proxy (load balancing)
# - "https 1.1.1.1:1080" # HTTPS proxy
# - "socks5 1.1.1.1:1080" # SOCKS5 proxy
always_direct:
- "localhost" # Direct access without proxy
- "127.*.*.*" # Local network
- "192.168.*.*" # Local network
# - "*.example.com" # Wildcard domain
always_proxy:
# - ".google.com" # Always use proxy for these domains
fallback: # Try proxy first, then direct
# - "example.com"
default: FALLBACK # Default behavior: FALLBACK | PROXY | DIRECTTo use this PAC server, configure your system's proxy settings with the following URL:
http://<IP-ADDRESS>:80/pac
- Open Windows Settings
- Go to Network & Internet > Proxy
- Enable "Use setup script"
- Enter the PAC URL:
http://<IP-ADDRESS>:80/pac
- Open System Preferences
- Go to Network > Advanced > Proxies
- Check "Automatic Proxy Configuration"
- Enter the PAC URL:
http://<IP-ADDRESS>:80/pac
- Open System Settings
- Go to Network > Network Proxy
- Set Configuration to "Automatic"
- Enter the PAC URL:
http://<IP-ADDRESS>:80/pac
- Open Settings > Network & internet > Wi‑Fi (or Wi‑Fi & network)
- Tap the connected Wi‑Fi network (or long‑press it) and choose "Modify network" or the gear icon
- Expand "Advanced options" or "Advanced" (depends on device)
- Under "Proxy", if there is an option for "Proxy Auto-Config" or "PAC", select it and enter the PAC URL:
http://<IP-ADDRESS>:80/pac