squid proxy modified to alter some pages/urls

CLOSED
Bids
3
Avg Bid (USD)
$233
Project Budget (USD)
$30 - $5000

Project Description:
I have a CentOS 5.5 machine where I run a squid proxy server, and need some help modifying squid so that it will alter certain pages/urls when being used as an http proxy. (Will also probably need some hand-holding while compiling squid and installing it over the existing squid installation.) The details for the "modified behavior" are listed in advanced details below.

## Deliverables

I have a CentOS 5.5 machine where I want to install a modified copy of the Squid proxy server, which works like normal squid except in the following cases:



- In one file (called for example /etc/squid/changeurlprefixes.conf, but you can call it anything), have a list of lines like
<http://www.somesite.com/foo> [http://www.othersite.com/bar
][1]This means that if the Squid proxy receives a request from a browser to fetch a URL beginning with "<http://www.somesite.com/foo>", Squid will *actually* replace that portion of the URL with "<http://www.othersite.com/bar>", and fetch that page and send it back to the user. The user's browser should not receive a redirect to the othersite.com URL; instead, the browser should stay on the URL beginning with "<http://www.somesite.com/foo>", but the actual contents will be fetched from the URL beginning with "<http://www.othersite.com/bar>". So if the user loads
[http://www.somesite.com/foo/whatever.txt
][2]the contents will be fetched from
[http://www.othersite.com/bar/whatever.txt
][3]although the user's browser will stay on
[http://www.somesite.com/foo/whatever.txt

][2]- In another file (called for example /etc/squid/insertlinesfordomains.conf ), have a list of lines in the format:

domainname.com stuff to insert goes here

This means that whenever Squid fetches any HTML page from the domain "domainname.com", it should modify the HTML content so that the text "stuff to insert goes here" is inserted either (a) right before the closing 'body' tag, if there is a closing 'body' tag on the page (do a case-insensitive search so it will find 'BODY' and 'body'), or (b) at the end of the page content, if there is no closing 'body' tag.
In those lines, the first space just signifies the end of the domain name, but any spaces after that, should be considered part of the text to be inserted, like "stuff to insert goes here".

One detail: if the URL matches one of the lines in changeurlprefixes.conf but it also matches one of the domains in insertlinesfordomains.conf , then the text specified in insertlinesfordomains.conf should *not* be inserted. So for example if the user accesses
[http://www.somesite.com/foo/whatever.txt
][2]and changeurlprefixes.conf contains the line
<http://www.somesite.com/foo> [http://www.othersite.com/bar
][1]and insertlinesfordomains.conf contains the lines
somesite.com blah blah
othersite.com blah2 blah2
then the page contents should be served from
[http://www.othersite.com/bar/whatever.txt
][3](because of the line in changeurlprefixes.conf) but *nothing* should be inserted before the closing 'body' tag of the returned page, i.e. the lines in insertlinesfordomains.conf should be ignored.

Also, I realize that if the user requests an [https://][4] URL, that Squid just proxies the CONNECT request and cannot see or modify the contents, so I realize that neither of these directives will work for [https://][4] URLs. (But the modified Squid proxy should still be able to *handle* CONNECT requests in order to fetch https:// URLs. A normal Squid proxy can do this, of course, so just don't break that functionality :) )

Here are some test cases I'm going to run to verify that the proxy works as needed:

First, put this line in changeurlprefixes.conf:
<http://www.google.com/foo> [http://www.peacefire.org/squidtest/subdir

][5]and put these lines in insertlinesfordomains.conf:
peacefire.org foo
google.com bar

Then with your browser set to use the squid proxy:

1) Access <http://www.google.com/foo/test.txt> . Verify that it loads as "abc" (which is the contents of the page http://www.peacefire.org/squidtest/subdir/test.txt ) and that the directives in insertlinesfordomains.conf are ignored in this case, i.e. no extra text is added
2) Access <http://www.peacefire.org/squidtest/body-tag.html> and verify that the string "foo" is inserted right before the closing "body" tag
3) Access <http://www.peacefire.org/squidtest/mixed-case-body-tag.html> and verify that the string "foo" is inserted right before the closing "body" tag
4) Access <http://www.peacefire.org/squidtest/no-body-tag.html> and verify that the string "foo" is inserted at the end of the loaded page
5) Access <http://www.google.com/> and verify that "bar" is inserted at the end of the loaded page

I'll also need to verify all the places that the code was changed from the original squid source code, so I may need some help with instructions on (a) downloading the squid source code, (b) using some 'diff' tool to verify all the places that the code has been changed, (c) compiling the modified source to create the new modified squid. (Hopefully the output will be installed to the place that squid is normally installed to, so it will respond correctly to commands like "service squid restart" and so on.) (Also note that we cannot give out root access to the server, so I'll need *instructions* on how to compile it, etc. but I can't give out the login for someone to do it themselves.)

Thanks and I look forward to working with you!

Skills required:
C Programming, Linux, Script Install, Shell Script
About the employer:
Verified
Public Clarification Board
Bids are hidden by the project creator. Log in as the employer to view bids or to bid on this project.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.


Hire superdav42
$ 600.1
in 14 days
Hire shkil
$ 50
in 14 days
Hire vw8040462vw
$ 50
in 14 days