CREATING A FORWARD PROXY WITH WEBRICK
-
Building a simple forward proxy in Ruby with WEBRick requires very little code. Here is a small sample that forwards all requests but for the example.com
domain, which it blocks.
The interesting bit is the handle_request
method. WEBRick provides us with the request and response instance for each request, so that we can check what’s being requested and block certain URLs. Since the response is also already available, we can even perform content filtering.