S3 is a good platform to save files without having to worry about storage ,connections and bandwidth.

S3 works on the idea of having buckets of content.The content of the bucket can be private or public or even access control managed.Even if you have a small amounting traffic on your website and the access patterns are every sparse the cost of S3 is low,Moreover Amazon gives about 5gb free every month.But once you reach a scale where you transfer 100 of gigabytes every month the cost per gigabyte for Amazon turns out very high.

Since I was part of a startup with very little cash to spare I came up with this an idea to save bandwidth without having to change the backend or migrate to another provider.The gist of the idea was to set up a reverse proxy server in front of the Amazon servers so every request gets to our proxy server first.Our proxy server in turns makes calls to the Amazon server to get the relevant files.Since a single server cannot handle a bunch load of requests, we also set up a load balancer which distributes requests based on the source ip address.

First we start by creating our amazon cache server.Here is the docker file for it.
The dockerfile creates the nginx servers which proxies traffic from s3.To build the docker image run ‘docker build -t s3cache .’
This config file sets up the reverse proxy and cache configuration for the nginx server.Make sure you replace bucket with your bucket name.This configuration is only applicable to public buckets without authentication.

Lastly we setup the haproxy server.

docker pull dockerfile/haproxy

You will also have to change the `server ip` to the nginx ip address.To get the ip address of a container run the following command

docker inspect -f "{{.NetworkSettings.IPAddress}}" <container id>


Once you get the ipaddress replace the `server ip` with it and run the following.This will run the docker image.

docker run -d -p 80:80 -p 8080:8080 -v &lt;dir&gt;:/haproxy-override dockerfile/haproxy


Replace dir with the directory that contains the haproxy.cfg file.
To check the status of your haproxy server visit this link
The username is admin and the password is password
Try making some requests you will notice that the requests will always go through the same server due to your ip address.

Getting rid of docker containers can be a pain.Its been about 6 months I have been using docker to build images for development purposes.
I took at my free space and I have only a couple of gigs free (5 gigs to be exact).It was time to clean this shit up.

docker rm $(docker ps -a -q)
#This removes all docker containers which have exited

docker rmi $(docker images -q)
#This deletes all the docker images.


For a couple of days I was looking for an extremely cheap vps provider on websites like lowendtalk .Having a vpn handy is really useful especially when using an network.After going through a lot of the providers and their infrastructure, I landing on host1plus.

Host1Plus is an extreme cheap VPS provider where the hosting starting from 2$ and goes up depending on the hardware specs you select.For a standard VPS with about 3-4 concurrent users a 256 MB ram computer is sufficient enough.Setting up this vpn was really easy all i had to do was install the pptpd package from the ubuntu repository.After some minor configuration changes I was up and running with a VPN that works and routes all my traffic though it.

The vpn was working fine for a couple of days until one day i could not connect to it.Seems like there was an issue with the host1plus network configuration due to which i was not able to reach my server.So i logged onto the admin dashboard and reinstalled the OS with their oneclick reinstall button.I had to go through the same process as before to setup the users , iptables ……

I had been playing around with chef for a couple of months now.So I though making a chef cookbook to install pptp and configure would make the setup really easy.Just running one command with smart default was the primary goal of this cookbook.

So I wrote a cookbook which is available on github.To use the cookbook you need chef installed.And you need to add the pptpd recipe to the node.json file.

Other details on how to use the cookbook is available on README.

Writing the cookbook was easy given chef has a very clean and neatly defined DSL to perform actions on the server.

I just recently created a cookbook for wordpress.The cookbook will automatically download and set up the database for you.To get started on using the cookbook.
1.If you are using librarian just add this line to the Cheffile.

cookbook 'wordpress', :git => 'https://github.com/h0lyalg0rithm/wordpress-cookbook'

otherwise you can download the cookbook from the here and extract it into your cookbooks directory.
2.Next just add the following to the run list or to the role file.


Docker is a light weight virtualization tool which uses the lxc(linux containers) to run its virtual machines.
Docker uses dockerfile to create the virtual machines.To setup the apache server with php on docker is very simple.
We first create a Dockerfile with the following command

touch Dockerfile 

This creates an empty file.Lets first get the base ubuntu files for the vm.

docker get ubuntu

.This will pull the ubuntu files form docker’s servers.Now we need to add the some commands to the dockerfile for docker to run.

FROM ubuntu
MAINTAINER Suraj Shirvankar

This instructs docker to use the ubnutu base files and also set suraj as the maintainer of the dockerfile.
We then run apt-get update which fetches the package info using aptitude.We also run the apt-get install apache2 to install the apache2 server.

FROM ubuntu
MAINTAINER Suraj Shirvankar
RUN apt-get update
RUN apt-get install apache2 -y

Since we will be using php with apache we install the php.We will also need the libapache2 module for php to work with apache2.

FROM ubuntu
MAINTAINER Suraj Shirvankar
RUN apt-get update
RUN apt-get install apache2 -y
RUN apt-get install php5 libapache2-mod-php5 -y

Now that php and apache is available we can start the apache2 service.

FROM ubuntu
MAINTAINER Suraj Shirvankar
RUN apt-get update
RUN apt-get install apache2 -y
RUN apt-get install php5 libapache2-mod-php5 -y
RUN /etc/init.d/apache2 start
CMD /bin/bash

Finally you run the docker build program.

docker build -t apache2 .