Keepalived instance not entering FAILED state

When a monitored interface goes down, the instance immediately enters FAILED state and the other instance gets into the MASTER state.

But, if you have a script block to check – say you are monitoring HAProxy – and HAProxy goes down the MASTER will not enter FAILED state, unless you do this:

Set the weight to a negative number (if MASTER priority is 101 and BACKUP priority is 100, the weight could be -2).

This way when HAProxy goes down, the Priority of the master will become 101 -2 = 99, the Backup with a priority of 100 will win the election and enter into MASTER state.

When HAProxy on the master comes back, it’s priority increases by 2 to become 101 again and if you have nopreempt disabled, this instance will enter the MASTER state.

Discourse with Docker on port 80

Discourse can cause you trouble if you have it running(listening) on a non-standard port inside the Docker instance. (the feed, google auth return url have the port and host info in them) (assuming you would like to serve requests from a standard http(s) port).

To make it work smoothly, I had to make it listen on standard port (80 in my case).
This is what I ended up doing:

Nginx(hostip:80) -> Nginx(dockerinsideip:80)

This method also extends to having multiple docker instance for different sites.
This is my nginx config on the host:

server {
    #where discourse sits
    location / {
        #this is also important for discourse to work as expected
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        #my docker instances internal ip

And, I removed http port mappings on my app.yml file.

missing scheme in email body url

Some mail service providers (Yahoo Mail exhibits this at the moment), do not like links that do not have a scheme(http/https for instance) and will make the link non-clickable by removing the href. The fix is simple:

<!-- link is not clickable -->
<a href="">Google</a>
<!-- link is clickable -->
<a href="">Google</a>

how to not run a cron job between certain datetimes

Say, I have a cron job entry and do want the job to run between 2013-02-01 9PM (Feb 1st 2013) and 2013-02-02 11AM (Feb 2nd 2013), this is one possible solution (in crontab).

* * * * * [ $(/bin/date "+\%Y\%m\%d\%H") -lt 2013020109 -o $(/bin/date "+\%Y\%m\%d\%H") -gt 2013020211 ] && /PATHTOMYSCRIPT/myscript

rsync only certain files

Create a file on on the origin server and use the –files-from option

cd /
rsync -anvi --files-from=/tmp/only_these_files . to-server:/
cat /tmp/only_these_files

WordPress + Nginx + Permalinks Rewrite rules

The following works for me:

  location /blog/ {
          index  index.php;
          # WordPress pretty URLs: (as per
          if (-f $request_filename) {
          if (-d $request_filename) {
          rewrite ^/blog/(.+)$ /blog/index.php?q=$1 last;
          # Enable nice permalinks for WordPress: (as per
          error_page  404  = /blog/index.php?q=$uri;

I have my blog here:
and my permalink structure is: /%postname%/