geeky notes on web (drupal) and .net (c#) programming, whichever prevails at the moment

 

How to configure a private proxy on your VPS

VPS hosting is very configurable. One can do things that were not imaginable before. One of such cool things is your own private proxy server.

Whether you need to do some things anonymously in internet, or you want to see how does a landing page looks, of an affiliate marketing offer, accessible only from a country you are not living in, but your VPS server is...

This is exactly the situation a felt myself in last couple of weeks, I was using internet proxy web pages, like hacksurfing.com or any other, but they are not always working correctly. Imagine, that the affiliate redirect link contains a little more complicated redirecting link done in javascript, which is far too much for hacksurfing to parse, and there is completely nothing you can do about that. (If you don't have a VPS, of course)

Lately I've been trying to find out how to configure a proxy on my JaguarPC VPS.

I have found some articles on internet but they were too common for me.

Here is a complete solution for you...

Configuration of apache private proxy on VPS

On JaguarPC VPS we have apache httpd service, and I think this private proxy configuration will work for anyone with apache. I have a plesk configuration, but I guess that doesn't matter, the private proxy is configured at apache level.

vi your apache configuration file /etc/httpd/conf/httpd.conf

find the proxy section which starts with ‹IfModule mod_proxy.c›. If you are reading this article, then probably that whole section in that file is commented out. Uncomment it. That's it, for a first step.

But...

It might not be wise to leave this proxy open to everyone, because it will be immediately used by hackers to hide their identity and do their evil plans :). Who will be guilty in this case? You, of course!

So we have to add this code: "Allow from 127.0.0.1" into that section. Meaning that traffic is allowed from local host only.

restart the httpd deamon: "apachectl -k restart"

Here is how that private proxy configuration section should look at the end:

‹IfModule mod_proxy.c›
        ProxyRequests On
        ‹Proxy *›
                Order deny,allow
                Deny from all
                Allow from 127.0.0.1
        ‹/Proxy›
         ProxyVia Block
‹/IfModule›

note that I used ProxyVia Block, which tells the private proxy server not to tell anyone that it is a proxy. I don't really know whether it's really important, but I like things look real :)

We are going to access the proxy via ssh tunnel, using a ssh program that supports tunnels. I always recommend putty, it really has everything!

So, open PuTTY, type your vps server's name in the host and go to tunnels section of putty's interface. Configure the tunnel so it maps your local port, let's say 8080, to remote http port: 80.
it should read:

source port: 8080
destination: localhost:80

When you connect to your VPS server with these settings, it will create a secure data tunnel, which we will use to access our private proxy configured at our VPS.

In your web browser, go to proxy servers configuration and type localhost:8080 as the proxy server name.

That's it!

When you visit some page, your browser goes through the secure tunnel made between putty and vps, then the data comes out of the tunnel at remote port 80, which is then correctly handled by the private proxy we've configured before!

Comments

===== Commented by Jim on 03 May 2010 =====

I knew I had seen this somewhere, but couldn't remember. Thanks for jogging my memory and sharing this info

- Peace

===== Commented by Anonymous on 31 May 2010 =====

I am stuck!

okay i have set up my vps proxy but i am getting block please help :)
here is my code

 ProxyRequests On
 <Proxy *>
   Order deny,allow
   Deny from all
   Allow from 76.227.60.27
 </Proxy>

when i put my real ip in line Allow from 76.227.60.27 i am getting block by the server
but when i use Allow from 127.0.0.1 then i am allowed access by the server.
what am i doing wrong please help sir from my thinking i should be allowed access but i could be wrong
thanks for the tutorial :)

===== Commented by Alex@vo1dmain on 31 May 2010 =====

You did it correct when you typed in 127.0.0.1, because you are accessing the proxy server via the ssh tunnel. Using ssh tunnel means to connect to a remote program and ask it to send and receive your packets. The address it is sending the packets from is 127.0.0.1, which is what you write to proxy configuration block.

Sure, you can configure it to use your real IP, but then you will have to set up your browser accordingly too: to use server's IP as a proxy address (not 127.0.0.1).

===== Commented by Lazzymonk on 09 August 2010 =====

Dynamic DNS Instead of IP

Im using my vps as a broswer proxy, rather than an ssh tunnel proxy.

Its working great when I put in my ip address. But my ip address changes.
I tried to use my dynamic dns address instread of an ip address but it didnt work.

Any ideas how i can do this? or if it is even possible?

Great mini tutorial by the way.

}