Web Proxy Server

To share assignment solutions and source code is not permitted under our academic honesty policy. Violation of this will result in your assignment submission attracting no marks, and you may face disciplinary actions in addition.

A web proxy server serves as an intermediary between a web server and a web client (e.g., a web browser). All web requests from the client and all responses from the server pass through the proxy server. This allows the proxy server to monitor the activities and when required filter requests and/or responses. For instance, the proxy server may keep an account of how much data is used by the client, block access to certain sites, transform or block some of the content received from sites, etc. Some proxy servers also cache responses so that multiple clients connecting through the same proxy server can benefit from data previously accessed by other connected clients.

High-level workflows of a web server, web client, and proxy server are illustrated below.

A web server

A web client

A proxy server is both a web server and a web client, and thus it

You are required to build a configurable HTTP proxy server. The proxy server should be built as a simple command-line application.

The proxy server should be capable of request filtering. This means the proxy server will not allow access to servers that are in black-listed domains. For example, if the the domain badsite.org is black-listed with the proxy server, requests to any host in this domain will not be allowed by the proxy.

The proxy server would also convert all the images that it passes through to grayscale images. The simplest (though not a fast) way to convert a picture to grayscale is to iterate through each pixel and set the RGB components of the pixel to the effective luminenance of the source pixel. In other words, R' = G' = B' = 0.30 R + 0.59 G + 0.11 B where R', G', and B' are the RGB components of the grayscale pixel and R, G, and B are the RGB components of the source pixel.

The proxy server should implement at least GET, POST, OPTIONS, and TRACE methods. The server should return the HTTP status code 501 (Method Not Implemented) for any method it does not implement.

A Via HTTP header should be added by the proxy server for all the requests and responses that pass through the server. The value of the Via header should be set to CS_Pr0xy.

An XML configuration file specifies four configurable attributes of the proxy server.

  1. The attribute Port specifies the port on which the proxy server listens. The defalut value for Port is 8080.
  2. The attribute BlackList specifies the domains that are disallowed when request filtering is turned on. This is a comma-separated list of domains. For example, specifying a domain auckland.ac.nz will disallow access to hosts www.math.auckland.ac.nz, www.auckland.ac.nz, etc. Access to hosts that are in the black list will cause the proxy server to return HTTP status code 403 (Forbidden). The default value for BlackList is an empty string, meaning that no domain is black-listed.
  3. The attribute UpstreamProxy specifies the upstream proxy server that this proxy should use. This is a colon (:) separated host and port pair. If the UpstreamProxy attribute is specified, then the proxy should connect via the host/port pair specified in the attribute, rather than making a direct connection to the web server. The default value for UpstreamProxy is an empty string, which means direct connection to the web server.

If an attribute is not defined in the configuration file, its default value should be used.

The configuration file should be named after your proxy server application and may have the file extension .config. If the configuration file does not exist, the default values should be used by the proxy server.

A sample configuration file is shown below.


<?xml version="1.0" encoding="utf-8"?>
<!--Proxy Server Configuration-->
<configuration>
   <appSettings>
      <add key="BlackList" value="badsite.org,verybadsite.com" />
      <add key="UpstreamProxy" value="gate.ec.auckland.ac.nz:8008" />
   </appSettings>
</configuration>

Sample Configurations

These are some sample proxy configurations.

  1. This configuration allows all accesses through the proxy server.

    
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
       <appSettings>
          <add key="BlackList" value="" />
       </appSettings>
    </configuration>
    
    
  2. This configuration allows all accesses through the proxy server, and uses gate.ec.auckland.ac.nz, port 8008 as the upstream proxy rather than connecting to web servers directly.

    
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
       <appSettings>
          <add key="BlackList" value="" />
          <add key="UpstreamProxy" value="gate.ec.auckland.ac.nz:8008" />
       </appSettings>
    </configuration>
    
    

Submission of Assignments and Marking

Please consult the Assignment Dropbox for the due date of the assignment.

You are to submit electronically:

  1. All source files in a ZIP archive
  2. A text file which specifies any information you may want to pass on to the marker. It should include instructions on how to compile and run.

Late submissions

This assignment will not be accepted after the due date of the assignment.

Marking

This optional assignment carries 2% towards the final mark for the paper.


Last updated Sat Mar 04 09:20:23 NZDT 2017 by mano.