code snippets

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...

Due to world best practices it is not 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 looking real, even if they are not :)

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!

related articles
I am still under the great impression of the VPS hosting I have moved to a couple of months ago. The speed and control are incredible! Read whole review about my new VPS hosting here

how to write a jquery script that rapidly increases the alexa rating of a drupal website

Finally I've taken a time and organized myself to make something that is supposed to increase my alexa pagerank.

Alexa rating is an important number that is often being looked at. For example tеxtlinkаds shows only two parameters to buyers - the PR of a page AND the alexa rating. nothing else! So we have to do something about it.

I have read a bunch of articles that advise to ask all your friends to install the alexa rating toolbar and ask them to visit your pages every day, so alexa records these visits and reflects that in numbers.

But it is a very ineffective way, as:

  • you may be in some niche that isn't connected with webmasters and internet at all, so your visitors may lack the knowledge how to write a comment, not speaking about installing the alexa toolbar for a firefox ("what's a firefox?" :)
  • even if they are, they will get tired of doing that, so that way is not lasting and eventually your alexa will go back down

That's why I guess alexa has made another way, which we need only to implement and the alexa rating will honestly report the real traffic on the site, thus boosting it up under 50000 in three weeks (that's what they say)

The redirection itself is pretty straightforward, for example, the link to this blog would look like http://redirect.alexa.com/redirect?http://www.vo1dmain.info

OK, then one could start and search-replace all his links, substituting them with the redirect links like that one. Fine, alexa rating boosts up, but.. You would lose all your google PR rating, because you will link to alexa from your every page several times each, thus making a great PR gift to to them :)

But we are not a charity organization, we will make it another way.

I have heard that there is a wordpress plugin that installs a pretty big javascript, which substitutes the real link with a redirect at the moment when user clicks it. Very elegant, because it's a clean way and everybody is happy.

This is exactly what I have done for Drupal, because there is no contributed module out there...

My final version of this javascript looks like this:

 

function alexa_click() {
  var link = this.href;
  if(link.indexOf("redirect")==-1)
  {
    link = "http://redirect.alexa.com/redirect?" + link;
    this.href=link;
  }
  return true;
}

function alexa_attach() {
  $('a').click(alexa_click);
}

if (Drupal.jsEnabled) {
  $(document).ready(alexa_attach);
}

Here is what it does: upon readiness of a page, it attaches itself to all links assigning it an alexa_click function. When any of them gets a click event, the javascript reads the link and prepends the alexa redirection. That's all! Effective and elegant.

A thing to mention - this script uses the built-into-drupal jQuery library, which is why the code snippet is so short. if you want to use it on any non-drupal site, you will need to download jQuery (40kb only!) and include it into your page.

After creating the script you save it somewhere in /misc among all other scripts and create a drupal php block which will contain only one line of code:

<?php
    drupal_add_js('misc/alexa.js');
?>

That's it!

Let's see how it'll work. Today it is the 19th of october and alexa rating of this a bit forgotten blog is 2.9mio. This my javascript was installed today, so I wonder how good is going to be the alexa number in november.

And of course I am still under the great impression of the VPS hosting I have moved to about a month ago. The speed and control are incredible! Read my whole review about my new VPS hosting here

Enhancing the drupal statistics: ip geolocation

Drupal statistics logs every access to a page. It is kind-of useful when the user is logged in, but there are times when you want to see where the user physically comes from. For this situation you can just go into "details" and see his ip address. Copy and paste it into some kind of online ip2location service and see the results.

This code allows you to shorten that cycle to just one click.  read more »

Powered by Drupal - Design by artinet