Skip to content

A Python-based caching proxy server that forwards HTTP requests between clients and target servers. Includes features like caching, request logging, blacklist/whitelist filtering, and concurrent connections. Bonus features include HTTPS support, SSL/TLS decryption for debugging, and an optional web-based admin interface.

License

Notifications You must be signed in to change notification settings

mohammadshouaib/CacheProxyServer-Using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Cache-Proxy-Server-Using-Python

A Python-based caching proxy server that forwards HTTP requests between clients and target servers. Includes features like caching, request logging, blacklist/whitelist filtering, and concurrent connections. And a web-based admin interface.

Caching Proxy Server

📖 Description

This project implements a caching proxy server in Python. The proxy server forwards requests from clients to target servers, relays back responses, and enhances performance through caching. It also provides features such as logging, request filtering (blacklist/whitelist), and concurrent client handling.


🚀 Features

Basic Proxy Functionality

  • Accepts client requests and forwards them to target servers.
  • Relays responses back to clients.
  • Supports HTTP (and optionally HTTPS).

Socket Programming

  • Manages connections using raw sockets.
  • Listens for client requests on a configurable port.
  • Establishes connections with target servers for data transfer.

Request Parsing

  • Extracts host, port, HTTP method, and URL.
  • Modifies headers (e.g., Host) as required.

Threading

  • Handles multiple clients concurrently via multithreading.

Logging

Logs details such as:

  • Client IP/port
  • Target server address/port
  • HTTP method and URL
  • Request/response timestamps
  • Error messages

Content Caching

  • Stores responses for repeated requests.
  • Supports cache invalidation based on headers (Cache-Control, Expires) or custom timeout.

Blacklist/Whitelist

  • Restricts access to specific domains/IPs.
  • Custom response for blocked requests.

🔒 Bonus Features

HTTPS Proxy

  • Supports tunneling HTTPS securely (without decryption).
  • Optional SSL/TLS decryption (MITM) using self-signed certificates. (For educational/debugging purposes only!)

Admin Interface

Web-based interface to:

  • View/manage logs
  • Inspect cache entries
  • Configure blacklist/whitelist
  • Display proxy usage statistics

🛠️ Requirements

  • Python 3.8+
  • Standard libraries: socket, threading, logging, datetime
  • SQLite3
  • (Optional) ssl for HTTPS MITM
  • (Optional) Streamlit + panda for the admin interface

📂 Project Structure

proxy-server/

  • │── proxy.py # Main proxy server implementation
  • │── cache/ # Cache storage (if file-based caching used)
  • │── logs/ # Log files
  • │── config.json # Configuration file (blacklist/whitelist, cache settings, etc.)
  • │── README.md # Project documentation

TO DO LIST

  • Scale up and use SQL DB
  • Make the logging cleaner
  • Work on Interface.py to make it more pro
  • Additional bonus features include HTTPS support, SSL/TLS decryption (MITM), and a web-based admin interface for managing the proxy.

▶️ Usage

Clone the repository

git clone https://github.com/your-username/proxy-server.git
cd proxy-server



About

A Python-based caching proxy server that forwards HTTP requests between clients and target servers. Includes features like caching, request logging, blacklist/whitelist filtering, and concurrent connections. Bonus features include HTTPS support, SSL/TLS decryption for debugging, and an optional web-based admin interface.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages