Skip to content


Create Your Own Web Proxy Server

Create Your Own Web Proxy Server

By Dark Politricks

If you have read my blog lately you will have seen a number of articles about the Internet and the loss of privacy and freedom that is being rapidly expanded by big brother and which will eventually turn the net into nothing more than a network for advertisers and a way for a government and big corporates to keep track of you.

If the powers that be succeed in removing or limiting the things that make people use the web in the first place then business will suffer as you will have a large network of sellers with no-one around to buy. It reminds me of a Twitter bot I came across the other day that was just retweeting other peoples messages by following certain hash tags. Looking at its profile you could see that it was following thousands of people and had thousands of followers itself a cursory check showed a funny case of Bots following Bots.

In fact the majority of all Internet traffic is bot traffic, search engine crawlers, content scrapers, RSS feed aggregators and so on. I reckon that the actual true percentage of web requests carried out by real humans at the end of a keyboard is actually less than 10%. This 10% are mostly made up of people social networking, downloading movies and music and most of all watching porn. These are you average Internet users and in all 3 areas porn, music and social networks they are being spied on for signs of copyright infringement, illegal activity e.g pedophilia, and the security networks have admitted scanning social networks for signs of malcontent by possible terrorists or subversionists.

Therefore Internet privacy is a major issue and has driven numerous people into the arms of proxy servers, web proxies, darknets and the like and not just because they have something to hide.

One of the major issues with the huge number of web proxies that have sprung up over the last few years is that they are run by hackers who are hoping you are stupid enough to use them to pass important data across such as logons and passwords or even bank details.

If you are not using a secure proxy then any information you pass through it will be available to the proxy server especially because most proxies only handle GET requests which means the data is visible not only in the address bar but also the log file on the web server. You can log POSTS but it takes a bit of work and the log files would be huge.

A recent Radio One interview with school children who were using web proxies to surf Facebook all day whilst they were supposed to be doing school work revealed a very worrying attitude to safety regarding proxies and didn’t seem to care that their logons were being passed into the hands of people who would use them for phishing and other scams.

If like me you are interested in computers and hacking (not the illegal sense) then its not too hard to create your own web proxy.

This could be hosted in a country that you wanted to be able to access e.g the USA so that you could access content banned by IP or it could be hosted on your own server so that at work or school if you wanted to view a site on a blacklist you could by accessing the content through the proxy. In fact there are many reasons for creating your own simple proxy and for that reason I have created an example that you can download the code for and use if you so wished.

The web proxy is pretty simple but has the following features:

  • Written in PHP, a popular scripting language.
  • The code is all in one page with comments and debug statements that can be switched on or off.
  • It offers you the ability to choose a different user-agent IE 7 or FireFox 3 or keep your existing one.
  • Once the content has been retrieved it parses the content and changed any links inside the HTML so that they are also re-routed through the proxy. Therefore you only need to use the initial search page to view your first page.
  • It contains a built in white-list of allowed domains which can easily be turned into a blacklist. If you allow other people to use it then you can control which domains they can or cannot view.

Anyone who is checking your outbound Internet traffic will most likely be blocking certain sites such as YouTube, Facebook and so on especially if you are at school or work. Therefore you could locate this page on a domain that is not blocked either by purchasing a hosting package or by turning your home computer into a server see this or this. Then instead of accessing the blocked sites directly you can go to your own web proxy and access them that way.

The benefit of using your own web proxy over those on the web are:

  • You know it’s secure as you control the code so no worries about hackers inserting malicious scripts into the source code or scanning your request for personal details.
  • You can control who uses it. You could put it at a location only you know about or add a simple password check to prevent unauthorised access.
  • You can expand the code to add further features and its a good way of getting into computer programming!

This example proxy is just something I have knocked up very quickly so please don’t complain about the code or functionality.

It has been done to show how easy it would be to create your own web proxy and any proper programmers out there would know how to do this anyway. For those of you who wish to use the code which can be downloaded here. I would recommend doing the following tweaks.

  • Modify the Crawler Method mycrawler_single so that it handles POST’s as well as GET’s.
  • Modify the Crawler Method mycrawler_single so that it can make requests through a proxy server itself. Tunneling will slow down content retrieval but will also make it more secure as long as you trust the proxy it’s going through.
  • Add more user-agents to the list of choices.
  • Modify the regular expressions that change the URLs so that they are scrambled in a certain way e.g by shifting the characters a couple to the left or using a hash function. You can then unscramble in the crawler method. This would prevent firewalls that scan for web addresses as parameters in other URLs as well as the main URL.
  • The function reformat_links currently reformats all src and href attributes so that they pass through the proxy. The code currently handles absolute and relative links but not formats such as ..\.\ I don’t like this format of referencing resources which is why I didn’t bother handling them. If you want to update this function then you can.
  • Reformat the code e.g put the code into a class, separate out the HTML and CSS etc. Its all in one file at the moment which makes it simple and easy to set up. Feel free to modify it.
  • Once you are happy with the code you should remove or comment out all calls to the ShowDebug function. Even when $DEBUG = False which prevents debug messages from showing its still an overhead to make these unnecessary function calls.

You can download the web proxy source code here: www.darkpolitricks.com/downloads/webproxy.zip

I did have an example running but too many naughty people were using it! So I have removed it.

Please read some more of my articles on Internet Privacy, How to avoid being logged and how to increase the performance of your computer and browser.

Are the days of Internet freedom coming to an end

Internet censorship and surfing anonymously

FireFox Performance Tweaks to boost your browsers speed

A how to guide to increase the speed and performance of your computer

Avoid Google spying on you as you use their search engine

Related Posts with Thumbnails

Posted in Computing, Dark Politricks Articles, Internet, Police State, Technology.

Tagged with , , , , , , .

Support #altnews & keep Dark Politricks alive

Remember I told you over 5 years ago that they would be trying to shut down sites and YouTube channels that are not promoting the "Official" view. Well it's happening big time. Peoples Channels get no money from YouTube any more and Google is being fishy with their AdSense giving money for some clicks but not others. The time is here, it's not "Obama's Internet Cut Off Switch" it's "Trumps Sell Everyones Internet Dirty Laundry Garage Sale".

It's not just Google/YouTube defunding altenative chanels (mine was shut), but Facebook is also removing content, shutting pages, profiles and groups and removing funds from #altnews that way as well. I was recently kicked off FB and had a page "unpublished" with no reason given. If you don't know already all Facebooks Private Messages and Secret Groups are still analysed and checked for words related to drugs, sex, war etc against their own TOS. Personally IU know there are undercover Irish police moving from group to group cloning peoples accounts and getting people booted. Worse than that I know people in court at the moment for the content they had on their secret private group. Use Telegrams secret chat mode to chat on, or if you prefer if you need to or buy a dumb phone with nothing for the NSA to hack into if you are that paranoid.

So if your not supporting this site already which brings you news from the Left to the Right (really the same war mongering bollox) then I could do with some. Even if it's just £5 or tick the monthly subscription box it will be much appreciated. Read on to find out why/

Why?

Any support to keep this site would be appreciated. You could set up a monthly subscription for £2 like some people do or you could pay a one off donation as a gift.
I am not asking you to pay me for other people's articles, this is a clearing house as well as place to put my own views out into the world. I am asking for help to write more articles like my recent
false flag gas attack to get WWIII started in Syria, and Trump away from Putin. Hopefully a few missiles won't mean a WikiLeaks release of that infamous video Trump apparently made in a Russian bedroom with Prostitutes. Also please note that this article was written just an hour after the papers came out, and I always come back and update them.

If you want to read JUST my own articles then use the top menu I have written hundreds of articles for this site and I host numerous amounts of material that has seen me the victim of hacks, DOS plus I have been kicked off multiple hosting companies, free blogging sites, and I have even had threats to cease and desist from the US armed forces. Therefore I have to pay for my own server which is NOT cheap. The more people who read these article on this site the more it costs me so some support would be much appreciated.

I have backups of removed reports shown, then taken down after pressure, that show collusion between nations and the media. I have the full redacted 28/29 pages from the 9.11 commission on the site which seems to have been forgotten about as we help Saudi Arabia bomb Yemeni kids hiding in the rubble with white phosphorus, an illegal weaapon. One that the Israeli's even used when they bombed the UN compound in Gaza during Operation Cast Lead. We complain about Syrian troops (US Controlled ISIS) using chemical weapons to kill "beautiful babies". I suppose all those babies we kill in Iraq, Yemen, Somalia and Syria are just not beautiful enough for Trumps beautiful baby ratio. Plus we kill about 100 times as many as ISIS or the Syrian army have managed by a factor of about 1000 to 1.

I also have a backup of the FOX News series that looked into Israeli connections to 9.11. Obviously FOX removed that as soon as AIPAC, ADL and the rest of the Hasbra brigade protested.

I also have a copy of the the original Liberal Democrats Freedom Bill which was quickly and quietly removed from their site once they enacted and replaced with some watered down rubbish instead once they got into power. No change to police tactics, protesting or our unfair extradition treaty with the USA but we did get a stop to being clamped on private land instead of the mny great ideas in the original.

So ANY support to keep this site running would be much appreciated! I don't have much money after leaving my job and it is a choice between shutting the server or selling the domain or paying a lot of money just so I can show this material. Material like the FSB Bombings that put Putin in power or the Google no 1 spot when you search for protecting yourself from UK Police with "how to give a no comment interview". If you see any adverts that interest you then please visit them as it helps me without you even needing to give me any money. A few clicks per visit is all it takes to help keep the servers running and #altnews alive!

However if you don't want to use the very obvious and cost free ways (to you) to help the site and keep me writing for it then please consider making a small donation. Especially if you have a few quid sitting in your PayPal account doing nothing useful. Why not do a monthly subscription for less money instead. Will you really notice £5 a month?


31 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. darkpolitricks says

    By the way if you are not a programmer and want to use the code you will need to remove the whitelist that is only allowing access to certain sites at the moment.

    Open the webproxy.php file up and on line 47 there is a variable pointing to a list of allowed domains e.g

    $whitelist = “domain1.com, domain2.com”;

    just set the string blank to allow access to any domains e.g

    $whitelist = “”;

    Otherwise you can limit the domains the proxy can access by adding them to that string. Putting a comma between each one.

    You will need to edit the html at the bottom of the page to remove the text that lists the domains you can view as well. Should have linked the two but I never bothered.

  2. Peter Blakely says

    Great article, I will be using this code to get round something my work blocked. Thanks

  3. Steve says

    Hi,

    Great article, I got your script working on my server: http://msn.meh626.com/webproxy.php

    I don’t know any PHP at all so I am wondering if it’s at all possible you could help me. I wish to use a proxy for just MSN only. I would like to be able to get Adium to login via a proxy on my web server (eg. msn.meh626.com) and to have the connection secured and to make it that only I can login.

    If you would be happy to any help I would greatly appreciate it.

    Best regards,

    Steve.

  4. darkpolitricks says

    So you only want to use this proxy for your own website? or other sites on the MSN domain?

    You can limit the domains that the proxy can access by editing line 47 of the code in the php file like so:

    $whitelist = “http://msn.”;

    This will ensure only sites on the msn sub domain can be accessed.

    Who is Adium? And what are they logging into and why do you need them to login through the proxy?

    Can you explain what is you are trying to achieve and why you need to do it?

    The web proxy code can handle requests on ports 80 e.g http and 443 https (secure) but if you want a secure connection e.g to access your site as https://msn.meh626.com you will have to purchase an SSL certificate if you haven’t already got one. However you will need permission to install it on the webserver.

    • Steve says

      Hi,

      Adium (http://adium.im/) is a free Mac OS X instant messenger client for services such as MSN.

      My work/school blocks the default MSN port (TCP 1863.) I would like to use a proxy to login via Adium to bypass the port block. Adium’s proxy settings allow you to enter the address, port, user-name and password.

      The MSN login server is: messenger.hotmail.com. I’ve added this address to the white list.

      Ultimately I would like the script only to work for me (have a username and password so only I can use it), only redirect traffic to the MSN login server and port and run headless (with no HTML – which I can do).

      Best regards,

      Steve.

  5. darkpolitricks says

    Well the code I have put up is only for a web proxy which will allow you to view webpages on ports 80, 443. Some schools/offices will have a list of websites e.g youtube that are blocked by URL/IP. Therefore by using a webproxy you can bypass this block by viewing these pages by going through the webproxy. The school/office will only see the request to the proxy page and not Youtube so it won’t be blocked.
    If you are trying to use an app like MSN through a proxy then you really need to look into using other forms of proxy servers as I don’t think the webproxy is suitable.
    You can find a list of proxies at the bottom of the following article:
    http://www.darkpolitricks.com/2009/12/internet-censorship-and-surfing-anonymously/
    Find yourself a good, fast proxy server on one of those lists and then use those details to bypass the port block.
    Do you even know which ports you can access? You may need to run a port scanner to find out what ports you have access to first however most proxies are available on common http ports e.g 80, 8080. 8000 etc.

  6. rg says

    great stuff, thanks !

  7. emulsify says

    Hi,

    first of all this is a get script. thank you loved it.

    i’m wondering is there any chance i can add a blacklist to it? whiltelist will grow and in time will be hard to manage but a blacklist won’t grow as fast. i’m interested to mod it a little would you point me to the chunk of code that process the whiltelist

    • darkpolitricks says

      well you can just change the bit of code that is currently looking whether a URL is IN the list (currently a white list) to make sure its NOT in the list turning it into a blacklist. so it would be a case of just modifying the whitelist code like so I guess

      if( strripos($lowurl, $val) !== false){
      ShowDebug(“This url $url is on whitelist matching $val”);
      $cansearch = true;
      break;
      }

      to be something liek

      if( strripos($lowurl, $val) === true){
      ShowDebug(“This url $url is on blacklist matching $val”);
      $cansearch = false;
      break;
      }

  8. zingoria says

    Hi,
    Many Thanks for Script
    I have uploaded the PHP on my webserver (FREE), I changed the $PROXYURL to my web server location, have also blanked the $whitelist = “”; to access all the sites
    but whenever i try to access any site using any user agent i get message in RED “The request could not be made”
    Need your Assistance.. Regards

    • darkpolitricks says

      That error is raised when the proxy tries to open the port to the relevant host. Therefore I am guessing that your web hosting company may have blocked outbound HTTP requests. You will have to check with them.
      Do you not have any error details apart from “The request could not be made”>? as the error message should appear next to it.

      The lines of code in question are

      if (!$fp)
      {
      ShowDebug( “ERROR! (“.$errno.”)”.$errstr);

      $urlinfo[“header”] = “”;
      $urlinfo[“html”] = “Error: $errno $errstr”;
      $urlinfo[“status”] = 400; // bad request
      $urlinfo[“content_type”] = “”;
      $urlinfo[“message”] = “The request could not be made. $errno $errstr”;

      return $urlinfo;
      }

  9. savalan says

    hey , ive found plenty of these php scripts which work great on google or other domans , but my problem is i wanna use something like that in home , i’m using HFS server to host my own website at home , but it doesn’t support the php or cgi … is there anyway to setup these phps at home ? i’m using win7 sp1 , but i have xp sp3 in my oracle virtualmachine , also ubontu as well , and i dont have problem by port forwarding etc , i can easily forward if requires , well i would be glad to get a mail from u to describe my problems and may get help as well 🙂 thanks , best regards .

    • darkpolitricks says

      Well to use PHP on windows you should install WAMP server on your home computer. You can then turn off IIS (in service manager OR in IIS) and then use port 80 as your webserver port for Apache to run PHP script.

      I use it on both Win XP and Win7. You can then leave your PC at home and follow one of the many online tutorials that explain how to turn your home PC into a webserver (locked down so only you can access it remotely etc). You then request your proxy page on your home PC from your remote PC.

      another way would be to just rent some server space in the country you want to access. E.g to watch UK TV from the USA rent a VPS server based in the UK, set up SQUID on PORT 3128 (many guides on how to do this) and then you have a proper poxy that handles all requests properly. Either that or just put mine or one of the many other web proxy scripts on this remote server and call the URL its on from wherever you are. Any requests it makes will be seen to be coming from the UK webserver so you won’t be IP blocked.

      Another way if you are using Windows and know basic coding is you can easily make use of your IIS webserver and write a simple web proxy using C# or VB.NET making use of the webRequest object.

      There are lots of online guides to making these requests and this one on Microsofts site explains how to make a simple GET request >> http://support.microsoft.com/kb/307023

      You would need some coding skils to replace relative links with absolute and so on but it’ easy if you follow the many guides online. Regular expressions are basically the same and it’s not hard to convert PHP code to C#.

  10. Yane says

    Hello..
    First of all thank you for the code.. It is really a big help to us in our research..
    I was just wondering, I edited the code and delete all the domains listed in the $whitelist so that I can access different websites. However, when I tried to access gmail.com I received this error
    “The specified URL could not be returned due to a status code of 400.”

    What could be the possible reason of this error and how should I fix this in order for me to login in my gmail using the web proxy server you created..

    Thank you very much for the help. .

    • darkpolitricks says

      Hi, this web proxy was really just a very very basic example to show how easily you can create one in PHP or any language. I wrote it a very long time ago in about an hour just as an example.
      You could probably download much better web proxies from the internet if you wanted.
      HTTP Status 400 is Bad Request. So I am guessing that gmail is returning that to you or the request is malformed somehow.
      I “think” I am using a very old/basic way of opening sockets to make requests e.g with fsockopen. You could try replacing the code with CURL to see that makes a difference.

      Some basic PHP to make a CURL request is below. This should get you started and then Google / PHP forums are everywhere to help you along.

      function CURLGetURL($url){

      // use CURL to make request

      $ch = curl_init();

      curl_setopt($ch, CURLOPT_URL, $url); // the url to retrieve
      curl_setopt($ch, CURLOPT_HEADER, 1); // return the header along with body
      curl_setopt($ch, CURLOPT_MAXREDIRS, 3); // follow this amount of redirects
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION,5); // follow redirects - change or paramterize
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return output as string
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //ignore issues with SSL certificates
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20); // connection timeout in seconds
      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.99 Safari/533.4"); // the useragent to connect with

      // get response and set array up

      $urlinfo["html"] = curl_exec($ch);
      $urlinfo["status"] = curl_getinfo($ch, CURLINFO_HTTP_CODE);
      $urlinfo["error"] = curl_error($ch);
      $urlinfo["headers"] = curl_getinfo($ch);

      curl_close($ch);

      // return hash table of response
      return $urlinfo;
      }

      // example
      $http = CURLGetURL("http://www.darkpolitricks.com");

      if($http){

      if($http["status"] == 200){

      // we got a valid 200 OK response - output html
      echo $http["html"];

      }else{

      // show error
      echo "returned a " . $http["status"] . " status error";

      // output error details
      print_r( $http["error"] );

      // output all header info
      print_r( $http["headers"] );

      }
      }

  11. beginner says

    I am very sorry but I’m a bit confused… What I am going to do with the code you just pasted? Am i going to add this function to the code you created??

  12. pinoy says

    Hi mr.Dark Politricks, Good evening,what is the meaning of this error “The url is not allowed to be accessed from this web proxy server.” , and do u have any video tutorials or another set of codes for web proxy server?

    Thank you.:D

    • darkpolitricks says

      Well the meaning is quite obvious – you are not allowed to access whatever url you are trying to from that page.

      If you read the article you will know why, its just an example to show how easy it is to write a web proxy.

      I am not going to let you use my bandwidth up by caning my test page you are supposed to download the code and modify it yourself if you want to access any URL.

      Thanks

      • Pinoy says

        gd evening sir,how can i access gmail.com and yahoomail.com in ur web proxy?tnx 😀

        • darkpolitricks says

          You probably can’t as they are very JavaScript / AJAX intensive websites and web proxies are not ideal for that sort of site as you would need to decompress any and all JS files (lazy loaded e.g after the page has loaded when they are needed) and then somehow work out which variables are links, src attributes and the like and sort them out (e.g push them through the proxy).

          Therefore you should read previous comments about this being an example and if you want to use a proxy to access your own email then use a proper proxy server e.g IP:PORT (details to find out such servers are in links on the site) and then you would set your browser to use those details instead of your current server.

          As I said previously this is just an example I knocked up very quickly to show how easy it is to do a basic proxy, you can download much better products for free online but for coders it is a starting point and nothing more.

  13. rich breton says

    Great work! One Question:
    is there a license for this code like bsd or mit?

    Cheers!

    • darkpolitricks says

      No – the reason being is that I basically knocked it up in a couple of hours as an example. You should really edit or improve the code (use CURL instead of FSOCKOPEN) or add code to handle POSTS, or encrypt the URLS so servers don’t spot “proxy” in any URL.
      It was bascially a guide to show people how easy it is to create your own web proxy – however I personally like to use “real proxies” e.g change the IP/Port no your browser users when surfing to bypass country blocks etc. A fully working web proxy has its limitations including pages based around lots of AJAX and JavaScript as URL’s can be split into variables e.g var a = window, b = document, c = “http://”, d = “mysite.com/mypage.htm” and then if that is loaded in a script you would have trouble knowing that a JS call to a.open(c+d) actually meant to open a new window to a URL.

  14. Joy Young says

    Hello!

    I have been looking for a web debugging proxy for Mac OSX 10.6 similar to Charles. I would like to make links or hash links generated from Facebook Platform – mainly Farmville. The Browser I am using is Chrome. I am brand new to this so any help you can provide is appreciated!

    Thank you, Joy Y.

  15. UI Man says

    Mr Politricks,

    Why do I keep on getting this error when everytime I input a url in the url field in the following web proxy:

    **”The specified URL could not be returned due to a status code of 400.”**

    And, how do I remove the restrictions so any website can be viewed apart from:

    $whitelist = “technicallypolitical.com,strictly-software.com,infowars.com,prisonplanet.com,hashemian.com”;

    I removed the above mentioned urls from the $whitelist and it worked as I was able to view google but then the 400 error started appearing.
    How would you change the code and where ?
    How would you add filters for banned words so if they are found in the page, title, meta tags, link and img paths then they are not served ?

    • darkpolitricks says

      This was a very very, quick example of writing a web proxy. I would not even call it good code and you could find better ones online I am sure. A 400 code means that the request was malformed. In other words, the data stream sent by the client to the server didn’t follow the rules. I wouldn’t use it to try and use Google as if you look at Googles source code it is all JavaScript now and a scraper like this would not be able to load and run it all.
      Well you would turn the whitelist into a blacklist and have sites you don’t want returned in the array instead and change the code to reflect that look up.
      Also I would use a simple regular expression to check for rude words or code like the whitelist, check the source out for the word in your array.
      It really is a quick knock up job and not meant to be used as a real web proxy just a basis for starting your own.

Continuing the Discussion

  1. Internet Censorship and Surfing Anonymously « Dark Politricks Retweeted linked to this post on January 9, 2010

    […] to quickly access some web based proxies you can pick from the following list or you can read my guide on creating your own web proxy which comes with an example and some code you can use to get […]

  2. Are the days of Internet Freedom coming to an end? « Dark Politricks Retweeted linked to this post on January 9, 2010

    […] Create your own web proxy server to bypass logging by your work or school and access banned sites. […]

  3. uberVU - social comments linked to this post on January 24, 2010

    Social comments and analytics for this post…

    This post was mentioned on Twitter by darkpolitricks: Read my latest article about how 2 create ur own #webproxy 2 avoid big bro on the #Internet http://bit.ly/53dtio download and off u go! #net…

  4. Are the days of Internet Freedom coming to an end? – Dark Politricks linked to this post on April 10, 2010

    […] Create your own web proxy server to bypass logging by your work or school and access banned sites. […]

  5. Internet Censorship and Surfing Anonymously – Dark Politricks linked to this post on April 10, 2010

    […] to quickly access some web based proxies you can pick from the following list or you can read my guide on creating your own web proxy which comes with an example and some code you can use to get […]

  6. Using Pirate Bay and their new Pirate Bay Browser | Dark Politics linked to this post on August 14, 2013

    […] benefits of running your own local webserver on your PC are many. You can make scripts such as web proxies, scrapers, scanners, BOTS, proxy hunters and many more cool tools. Plus the great thing is that the […]



Some HTML is OK

or, reply to this post via trackback.



css.php