This is a simple concurrent caching Web proxy that accepts HTTP 1.0 requests from clients, forwards them to end servers, and then sends the replies back to the clients. The proxy caches objects returned by the end servers, and attempts to satisfy requests from clients from the cache before forwarding the requests to the end servers.
It was implemented as an exercise for better understanding the HTTP protocol, networking, concurrency and the inner workings of a web proxy.
The initial code is part of the Proxy Lab and the implementation follows the lessons from the book Computer Systems's - A Programmers Perspective, particularly on Network and Concurrent Programming.
The main implementation is on file src/proxy.c
. The other files are provided from the handouts for the lab. If you want to try it yourself, get it here.
- Developed/tested on Linux
gcc
C compilermake
utilitynetstat
network tool andpython
for running the tester (driver.sh
)ab
for running the stress test (stress.sh
)
- Handles regular HTTP GET request and forwards it to remote server
- Does concurrent request by spawning a separate thread per request
- Apply a simple FIFO cache policy for small static contents
- Implements HTTP CONNECT method to enable HTTPS navigation (no caching)
Since this is an exercise/educational project, the implementation is kept minimal and very simple.
- No security
- Not very robust (needs better error handling)
- Cache implementation is minimal (lacks logic for invalidation, etc.)
- No advanced features (only minimal HTTP standard)
- Etc.
Compiling the tiny proxy:
$ cd src
$ make clean
$ make
Compiling the tiny HTTP server:
$ cd src/tiny
$ make clean
$ make
Check src/README
and src/tiny/README
for more details.
Recompile and run the tiny web server (in background) and the tiny web proxy (foreground) for general testing/development.
$ ./start.sh # from project root
Running the provided driver test script that launches the proxy, a tiny web server and makes some requests to check the implementation and grade it.
$ cd src
$ ./driver.sh
Stress testing using apache benchmarking tool (ab):
$ cd src
$ ./stress.sh