Uncategorized

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

HOW TO : Dowload content from Oracle Metalink (Support) using wget

The usual process for a DBA to download files from Oracle Metalink (support) site is

  • Login to Metalink from his/her workstation
  • Download the file
  • Upload the file to the database server
  • Use the file

Say your database is in a data center and your workstation doesn’t have high speed connectivity to the data center, you can use the following trick to download content to a l[u]inux server in the data center that has Internet connectivity (and hopefully it is not your database server 🙂 ).

  • Log into Metalink from your workstation
  • Grab the link to the file/content you want to download (for example, we recently tried to download clusterware for Oracle 11G, and the link was http://download.oracle.com/otn/linux/oracle11g/linux.x64_11gR1_clusterware.zip)
  • Log into a server in your data center (it should have connectivity to the Internet and also to your database server)
  • Download the file using wget

[bash]wget http://download.oracle.com/otn/linux/oracle11g/linux.x64_11gR2_clusterware.zip –user ORACLE_ID –password ORACLE_ID_PASSWORD[/bash]

  • Replace the link with the link to your content and use your Oracle ID and password.
  • The file downloaded will have a strange name since wget  appends the sessionID to the end of the file. In the example I used above, the name of the file was “linux.x64_11gR2_clusterware.zip\?e\=1297470492\&h\=a66b265cc967a68c611052cb8e54356f
  • Rename the file and strip off the unnecessary data in the name using mv

HOW TO : Capture HTTP Headers using tcpdump

Quick how to on capturing HTTP headers using tcpdump on a web server (running Linux).

    • On the web server, issue the following command

      [bash] tcpdump -s 1024 -C 1024000 -w /tmp/httpcapture dst port 80 [/bash]

        • Stop the capture by issuing the break command (ctrl + c)
        • Open the capture file (httpcapture in this example) in wireshark and check out the headers under the  the HTTP protocol

        Overheard : Comment about being a true Motivater

        I was interviewing a candidate for a job opening at my work. I asked him how he motivates his team and he made this comment about how you truly measure if you can motivate a person

        Think of a 16 year old working part time at a retailer. She is just working to earn money to buy some lipstick or perfume. Think how you can motivate her to work on a thanksgiving weekend!!