2011

HOW TO : for loop in bash

Quick post for my own reference down the road. the “for” loop comes in very handy, when you want to perform the same task on multiple items in a bash shell.

For example, I wanted to query the DNS results of a couple of sub domains (blog.gogoair.com, pr.gogoair.com, tracker.gogoair.com), I can do it the normal way (that 99% of us do 🙂 )

[code] dig blog.gogoair.com

dig pr.gogoair.com

dig tracker.gogoair.com [/code]

Or, I can use the for loop function and do this

[code] for i in {blog,pr,tracker}.gogoair.com; do echo "$i" ; dig +short "$i"; done [/code]

Got to love technology :).. Makes you lazy!!..err I meant to say productive.

Thx to Cliff for the inspiration.

Celebrating Ugadhi

Jhanvi and I visited India in April and were lucky to celebrate Ugadhi with our family back home. Ugadhi is the an important festival in South India and is essentially the celebration of the begenning of a new year (yep.. new year in April 🙂 ). One of the specialities of Ugadhi in Andhra Pradesh is something called “Ugadhi Pachadi”. It is a mixture of 6 ingredients (Neem Flower, Jaggery, Red Pepper, Green Mango, Salt and Tamarind) which designate the different “tastes” of life (bitter, sweet, hot, salty, tangy etc).

I haven’t been able to celebrate Ugadhi with my family for more than 10 years. So it was a special occasion. And mom went all the way to make it even more memorable. Here are some pictures.

Hanging Mango Leaves

Garelu

Ugadhi Pachadi : Ingredients

Ugadhi Pachadi : Final

Thanking the divine ones

RESOLUTIONS : 2011 : April Update

Another late update. I really want to post these updated in the first week of the month, but something or the other always stops me from doing it. Maybe one of my resolution should be to post updates on resolutions on a timely basis :).

  • Lose the Gut
    • This is the first month, where my weight at the end of the month was higher than the weight at the beginning. And I blame all of it on the yummy food I had in India.
    • This was also the first month during which I didn’t measure my weight on a daily basis for more than 80% of the time.
    • Here is how the graph looks like
    • I feel like I have hit a plateau in my effort to lose weight. And I think I know why. I stopped exercising (whatever little I used to do 🙂 ). One small resolutions and so many issues :).
  • Increase traffic to kudithipudi.org
    • Another goal I didn’t do anything about in April. In fact, this is probably the one goal where I have consistently lagged behind. I haven’t been writing as much as I want to. Plenty of ideas, but at the same time plenty of excuses 🙂 to not write. But does it really matter? I just need to get it done.
  • CISSP Certification
    • I started preparing for the certification. I think I should just schedule the exam, so that I have a deadline to meet.
  • Vacation
    • With the recent vacation in India, I think this resolution has been met.  One down, three more to go 🙂

RESOLUTIONS : 2011 : March Update

A bit late on posting my monthly updates :). I blame it on the travel to India and poor connectivity. Here come the updates

  • Lose the gut.
    • I continue to lose weight thanks to the simple diet technique. My lowest point so far is 179.6lbs.. That is nearly 15lbs lower than my max weight this year!! :). Here’s a graph of my daily weight.
    • I haven’t been exercising as much as I used to. Although I have multiple excuses, I don’t think it matters. I should just suck up and stick to the plan. I think my travel to India in April is going to hinder the progress. But I promise to get back on track.
  • Increase traffic to Kudithipudi.org
    • This is probably the one goal that I haven’t done a good job making progress on. Although I intended to write several new posts, I didn’t manage to publish them. Here’s a snapshot of March 2011 traffic compared to 2010. It is higher, but not at the level where I want it to be at.
  • CISSP Certification
    • Although I did not make direct progress on this goal, I was able to improve my knowledge and network in the security arena by attending the Netsecure ’11 seminar arranged by IIT.
  • Vacation
    • Jhanvi and I are going to be in India in April for 3 weeks. So expect a ton of pictures 🙂 in the next few weeks.

HOW TO : Enable global reverse proxy with certain exclusions in Apache

Say you want to enable reverse proxy on a site powered by Apache Web Server where all traffic to the web site it reverse proxied to a different server, but you want to exclude certain paths from being reverse proxies. I don’t know why you would want to do that :).. but we ran into that scenario at work and I wanted to document the config for future reference. The picture below shows a high level view of the traffic

  • Ensure the following modules are being loaded in Apache.

[bash]

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so

[/bash]

  • In the virtual host configuration for kudithipudi.org add the following lines

[bash]

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /static !
ProxyPass /media !
ProxyPass / http://INTERNAL_SERVER:8888
ProxyPassReverse / http://INTERNAL_SERVER:8888

[/bash]

HOW TO : Trick to find out your IP address from a web server farm

This is a quick trick I came up with to find out the IP address of a client that is trying to access a farm of web servers that you have access to. The diagram below shows the network path for a typical web server.

You have a client that might be sitting behind a (or multiple) proxy server. And there is a load balancer involved because you have multiple web servers for redundancy.

We were recently working on some rewrite rules for our web servers at work and we needed to find out what IP address the web servers were seeing the client traffic come from. Couple of challenges

  • Which web server do you check? The load balancer can send you traffic to any server.
  • What IP address are you going to look for? Wait that is the original problem right :).

The web servers usually write an entry to the error log when they serve a 404 error. So we can use that to figure out which web server you are hitting and what IP address the web server is seeing you as. Here’s the trick

  • On the client side go to http://WEBSITE_ADDRESS/Get_Me_My_IP (or some other URL, which you know doesn’t exist on the web site)
  • On the server side, grep for “Get_Me_My_IP” in the web server error logs

Here is an example, I ran on this website (https://kudithipudi.org)

[bash]
root@samurai:/var/log/apache2# grep -i what_is_my_ip access_kudithipudi.log
199.27.130.105 – – [04/Mar/2011:16:07:18 +0000] "GET /what_is_my_ip HTTP/1.0" 40 4 5495 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.14) Gecko/2 0110218 Firefox/3.6.14 ( .NET CLR 3.5.30729; .NET4.0E)"
[/bash]

  • From this entry I can figure out that my client is appearing as “199.27.130.105” to the web server.

RESOLUTIONS : 2011 : February Update

Here come the monthly updates on my 2011 resolutions.

  1. Lose the gut.
    • Continuting to follow the diet in Tim Ferri’s book. I seemed to have plateaued in February (between 185 – 187 lbs), so I kicked it up a notch with chemicals. OK.. no steriods. Just some good old garlic. Today, I weighed 183lbs!!.. That’s 11.5lbs in 2 months. Here’s a chart of my daily weight since 1/3/2011
    • I think the trick is to really keep the diet simple, so that you don’t have to worry about what you are eating. The 2 egg whites for breakfast is great. In March, I am planning on extending the “keep it simple” to lunch. Some beans and spinach are going to do wonders.
    • I also started practicing Yoga on weekends. This is another thing, once I get up to speed and more comfortable, I plan on doing every day.
    • My running distance is up to 4 miles now.. Up from a embarrassing 1 mile :). And this is the same guy that used to run Marathons :).
  2. Increase traffic to kudithipudi.org
    • I published 7 posts in Feb 2011. Not as many as I wanted, but the increase in traffic has been pretty impressive so far. Here is a snapshot of a Google Analytics report comparing the first two month periods of 2010 and 2011. (click on the image for a larger size. The blue line shows 2011 traffic and the green line shows 2010 traffic)
    • I still didn’t publish the posts I have been meaning to for sometime now 🙂
  3. CISSP Certification
    • No progress on this yet :(..
    • I did start the process to form a hacker group at work to discuss and brain storm new technologies. Not close to getting certification, but something to keep the mind busy.
  4. Vacation
    • Our trip to India is finalized. I even bought the tickets!! And we are going to fly through Abu Dhabi. How abt that for a 3 hour layover vacation 🙂 ?

Overheard : Comment about perception

Comment by Mark Horstman on his recent podcast regd managing a massive workload increase

We don’t see the world as it is, we see it as we are

I believe this a famous quote.. don’t know who the original author is. But wanted to note, since it is a pretty deep :).

I highly recommend Mark and his partner Mike’s podcast “Manager Tools” and “Career Tools” to every professional. Well worth the time.

HOW TO : Setup Global Redirect in Lighttpd

If you have ever managed a web application, you know you have to take it down at times :). And you usually want to show an simple page stating that you are down for maintenance. Here is a simple way to setup a “maintenance” splash page. The assumption is that you have a Linux server to host the maintenance page.

  • Configure lighttpd (HTTP Server) on the server using instructions from this article on Cyberciti.
  • Edit the lighttpd.conf file and add the following line in your site configuration

[bash] server.error-handler-404   = "index.html" [/bash]

  • Name your maintenance page as index.html and upload it to the document root (in this example, it is /var/www/html)

You are essentially telling the web server to display index.html whenever the user is trying to access content that is not present on the server. And since there is no content on the server other than the index.html, the web browser will always display the index.html page..