| Instructor | Omprakash Gnawali |
Web proxies allow caching of webpages so that many local clients can access the same webpage from a nearby server without having to contact the remote server. For example, we have clients A, B, and C in our local network. A accesses a webpage: http://www2.cs.uh.edu/~gnawali/. If node A was connected to the Internet through a proxy server, the request first goes to the proxy server. The proxy server then fetches the page, caches it, and sends it to node A. Later, when node B and node C request the same page, if they are also using the same proxy server, the proxy server will return the cached page. Thus, we were able to satisfy three requests using a single remote fetch.
We will test your proxy server using Chrome. For testing, you should be able to use any web browser as long as it can use a standard compliant proxy server.
Components of a proxy server Here are the various tasks performed by a proxy server:
You might also might telnet useful. For example, you can send HTTP request to a web server using telnet.
Experimenting with HTTP using these tools will speed up your exploration of essential parts of HTTP protocol that you will need to understand concretely for this project.
Proxy Chaining. Your HTTP proxy must allows proxy chaining. That is we should be able to configure your proxy to use another proxy upstream.
Data Encryption. Encryption the communication between your proxies. Do this with the encryption algorithm supported by the downstream proxy. In this project, there is only one encryption algorithm. We will use substitution cipher. You compute the ciphertext by adding k to each byte with a wrap around at the byte boundary. The value k is mod 10 of the in port of the downstream proxy (proxy closer to the web browser client) and negotiated with the upstream proxy.
Data Compression. Compression of web pages between your proxies. Do this with the compression algorithm supported by the downstream proxy. In this project, there is only one compression algorithm. We will use run length encoding. For a given input byte stream, you compute the output by tagging each byte with the number of time the particular byte appears consecutively in the intput stream modulo 255. Examples:
| Input | Output |
| abbc | 1a2b1c |
| a(repeated 500 times) | 255a245a |
Note that in the examples above, the number preceding the character is a byte, not multiple bytes. For example, when we write the output for the second input above, we will write four bytes to the output: the first byte with the value 255, the second byte with the value ord(a), the third byte with the value 245, and finally the fourth byte with the value ord(a). That is four bytes, and not 8 bytes like what it appears in the text representation.
Routing. Routing of requests depending on the URL. Choose different upstream proxy depending on the URL being requested. If the length of the URL is even, we forward the request to the upstream proxy that has even port number. If the length of the URL is odd, we forward the request to the upstream proxy that has odd port number. To test this feature, we will use a scenario that has only two upstream proxies, one on even and the other on odd ports.
Load Balancing. Load balance among multiple upstream proxies.
We will standardize the messages between the proxy servers to request and use these extensions. Standardization of messages allows us to mix and match proxy servers written by multiple teams to create a chain or tree of proxies.
./proxy -listen port -supports plain|compress|encrypt [-server port1 port2 ... portn -use compress|routing|balance|encrypt] Example 1: ./proxy -listen 8080 -supports plain Example 2: ./proxy -listen 9001 -supports compress encrypt plain ./proxy -listen 9002 -supports compress plain ./proxy -listen 9003 -supports compress plain ./proxy -listen 9004 -supports compress plain ./proxy -listen 8080 -supports plain -server 9001 9002 9003 9004 -use compress routingThe part starting -server is optional. The first example starts a standalone proxy server at port 8080. You can then use your web browser to connect to this proxy with the hostname of the machine where you launched this proxy and the port specified in the command line. The second example starts a series of proxy servers. It starts four proxy servers at ports 9001..9004 with different capabilities. Then it starts a proxy server at 8080 that supports a plain HTTP request. This proxy does not send the HTTP request directly to the URL in the request; instead it routes the request to one of the proxy servers 9001..9004 and expects that the HTTP requests come back in compressed form. As shown in the examples, -supports and -use may have multiple values.