How to limit connections per User IP in Apache 2.2 CentOs

If you are a system admin or a webmaster, you will face this question at some point of time. How do I limit connections per user ip in Apache 2.2? Generally, you get good users visiting your site who use the site normally requesting one or two page at a time. But then there are a few malicious user who would want cause grief to you and your server by overloading the server with requests. To handle such malicious user, you need the mod_limitipconn module. This module keeps check on the number of connections a single ip can make simultaneously. There are configurable options that help you tune this module. So, now to the point.. How do I install this on my server?

I am outlining the steps for my server, ie. CentOs 5.2 with Apache 2.2

  • wget http://dl.atrpms.net/all/mod_limitipconn-0.23-4.el5.x86_64.rpm
  • rpm -i mod_limitipconn-0.23-4.el5.x86_64.rpm
  • vi /etc/http/modules/ipconn.conf

    Add following to the content of ipconn.conf
    # LimitIPConn module limits the number of connection to apache
    # per IP address. This helps in limiting the simultaneous downloads and will help
    # prevent slow users from blocking your servers.
    #
    <IfModule prefork.c>
    LoadModule limitipconn_module modules/mod_limitipconn.so
    </IfModule>

  • Make sure ‘ExtendedStatus‘ is ON in /etc/httpd/conf/httpd.conf
  • You will have to configure the module for each of your virtual host that you need to implement the limitip for.

    <IfModule mod_limitipconn.c>
    <Location /forums>
    MaxConnPerIP 3
    # exempting images from the connection limit is often a good
    # idea if your web page has lots of inline images, since these
    # pages often generate a flurry of concurrent image requests
    NoIPLimit image/*
    </Location>
    <Location /video>
    MaxConnPerIP 1
    # In this case, all MIME types other than audio/mpeg and video*
    # are exempt from the limit check
    OnlyIPLimit audio/mpeg video
    </Location>
    </IfModule>

  • Save the config file and test the new configuration “/etc/init.d/httpd configtest”. If you get “Syntax OK”, then all you need to do is restart the server and you are good to go.

This is a brief guide on how I got mod_limitipconn working on my server. If you have any questions, please feel free to post in comment and I will try to answer your questions.

Posted in Tips, linux | Leave a comment

Error encountered while installing Microsoft Office

If you encounter an error while installing Microsoft Office, then you need to do the following steps to resolve it. From an administrator account, do the following:

  1. start -> run -> Type “msconfig” -> click on ok
  2. Check the box selective startup
  3. Under selective start up uncheck the 1,2 and the 4 options
  4. Click on the services tab
  5. Check hide all microsoft services
  6. Click on disable all
  7. Click on apply and ok
  8. When asked, restart the computer
  9. Wait for restart to complete and then log on to administrator account
  10. Start -> Run -> Type “msiexec.exe /unregister” ->  click on ok
  11. Start -> run -> Type “msiexec.exe /regserver” -> click on ok
  12. Now insert the disc and install the office software

Hope this helps you in case if you encountered an error while installing Microsoft office.

Posted in windows | Leave a comment

How to sync time in Linux, Unix

Very often, one would have seen that the server/desktop time goes off by some seconds/minutes than the standard time.

It’s very easy to sync up the time in Linux/Unix. Issue the following command as ‘root’ to update the time.

ntpdate pool.ntp.org

To automate this time update, you can set up a cron job to run once every week.

Posted in linux | Leave a comment

GoDaddy NameServer not registered

Recently, I moved over to a new host with a dedicated box and I had to setup the nameservers for my domain kpsolution.com. In Godaddy’s domain manager, I tried to change the nameservers to my domain like ns1.xxxx.com and ns2.xxxx.com, but got an error that “Nameserver not registered“. This was puzzling as I had setup the slaves dns entries on my server correctly but Godaddy complained that “Nameserver not registered”.

Then I found that in the lower left corner, there’s a box with “Host Summary”. You have to add your nameservers entry in that box first. So click on “Add” besides “Host Summary” and it will present you another dialog where you can enter your subdomain and the ip address to point to your server. Once you have added your nameservers in Host Summary, then you can click on “Manage” besides “NameServers” and add your nameservers ns1.xxxx.com and ns2.xxxx.com there and Godaddy will happily accept it!!

Hope this saves you your time and help you avoid pulling your hair!!! :)

Posted in linux | Tagged , , , | Leave a comment

Google reporting site may harm your computer

Today, 31st January 2009, 10 AM EST, Google has been reporting all sites whatsoever as a malware sites with the error “This site may harm your computer”. Even sites like microsoft, google, yahoo, cnn were all affected because of this bug.

Google Error - This site may harm your computer

Google Error - This site may harm your computer

As you see in above screenshot, I saved the snapshot of the “yahoo” search keyword on google and all sites were reported as malware sites and when you click on any urls, it would redirect to a page warning you of that site. This is ridiculous and it is giving badname of your site to your visitors. Google has got no right to do so.

Posted in Company Updates | Tagged , | Leave a comment

Use RSYNC to backup data on a second hard disk

On a production server, if you have two hard disk and do not want to spend extra $50 each month, then you could use rsync to backup the data from your main disk to the second disk. It’s very easy to setup. All you to do is use to the following scripts. Save the following script as /disk3/rsync_backup.sh

#!/bin/bash
unset PATH

# USER VARIABLES
BACKUPDIR=/disk3                            # Folder on the backup server where the backups shall be located
#KEY=/root/.ssh/id_rsa                        # SSH key
#MYSQL_BACKUPSCRIPT=/root/my_backup.sh        # Path to the remote mysql backup script
#PRODUCTION_USER=root@production.server.com    # The user and the address of the production server
EXCLUDES=/disk1/backup_exclude                # File containing the excluded directories
DAYS=60                                        # The number of days after which old backups will be deleted

# PATH VARIABLES
SH=/bin/sh                                    # Location of the bash bin in the production server!!!!

CP=/bin/cp;                                    # Location of the cp bin
FIND=/usr/bin/find;                            # Location of the find bin
ECHO=/bin/echo;                                # Location of the echo bin
MK=/bin/mkdir;                                # Location of the mk bin
SSH=/usr/bin/ssh;                            # Location of the ssh bin
DATE=/bin/date;                                # Location of the date bin
RM=/bin/rm;                                    # Location of the rm bin
GREP=/bin/grep;                                # Location of the grep bin
MYSQL=/usr/bin/mysql;                        # Location of the mysql bin
MYSQLDUMP=/usr/bin/mysqldump;                # Location of the mysql_dump bin
RSYNC=/usr/bin/rsync;                        # Location of the rsync bin
TOUCH=/bin/touch;                            # Location of the touch bin

##                                                      ##
##      –       DO NOT EDIT BELOW THIS HERE     –     ##
##                                                      ##

# CREATING NECESSARY FOLDERS
$MK $BACKUPDIR
CURRENT=$BACKUPDIR/current
OLD=$BACKUPDIR/old
$MK $CURRENT
$MK $OLD
# CREATING CURRENT DATE / TIME
NOW=`$DATE ‘+%Y-%m’-%d_%H:%M`
NOW=$OLD/$NOW
$MK $NOW

# CREATE REMOTE MYSQL BACKUP BY RUNNING THE REMOTE BACKUP SCRIPT
# $SSH -i $KEY $PRODUCTION_USER “$SH $MYSQL_BACKUPSCRIPT”

# RUN RSYNC INTO CURRENT
#$RSYNC                                                            \
#    -apvz –delete –delete-excluded                        \
#     –exclude-from=”$EXCLUDES”                                \
#      -e “$SSH -i $KEY”                                        \
#       $PRODUCTION_USER:/                                        \
#        $CURRENT ;

// No Compression
$RSYNC                                                            \
-apv –delete –delete-excluded                        \
–exclude-from=”$EXCLUDES”                                \
/                                \
$CURRENT ;

# UPDATE THE MTIME TO REFELCT THE SNAPSHOT TIME
$TOUCH $BACKUPDIR/current

# MAKE HARDLINK COPY
$CP -al $CURRENT/* $NOW

# REMOVE OLD BACKUPS
for FILE in “$( $FIND $OLD -maxdepth 1 -type d -mtime +$DAYS )”
do
#    $RM -Rf $FILE
$ECHO $FILE
done
exit 0

Save the following to /disk3/backup_exclude. Essentially, these are the files/folders you do not wish to backup using rsync.

/disk3/
/bin/
/boot/
/dev/
/lib/
/lost+found/
/mnt/
/opt/
/proc/
/sbin/
/sys/
/tmp/
/usr/
/var/log/
/var/spool/
/var/lib/php4/
/var/lib/mysql/

Posted in linux | Tagged , , | Leave a comment

Open ODT file in Microsoft Word 2007/2003

Many times you may have to open the openoffice documents (.odt) in microsoft office. To do so, you will have to install the SUN ODF Plugin for Microsoft Office and then you would be able to open the open officie documents in microsoft office.

- Install Sun ODF Plugin for Microsoft Office.
- Open ODT document using File > Open, or by double-clicking the ODT file and when prompted for the application to open it with, choose Word.

Posted in windows | Tagged , , , , , | Leave a comment

PHP Startup: Unable to load dynamic library php_openssl.dll

You might get the error: “PHP Startup: Unable to load dynamic library php_openssl.dll. The operating system cannot run %1“, when you are trying to start the apache server in the error.log file.

Basically what this error is trying to mention that there is an issue with your php_openssl.dll and a possible mismatch with other depending libraries. To resolve this, follow the below steps:

1. Rename ‘ssleay32.dll’ and ‘libeay32.dll’ in c:\windows\system32 to ‘ssleay32.dll.old’ and ‘libeay32.dll.old’ respectively.

2. Copy ‘ssleay32.dll’ and ‘libeay32.dll’ from your PHP folder to the system32.

3. Restart the apache webserver.

This should get your problem sorted!!

Posted in php, windows | Tagged , , | Leave a comment

Not enough storage is available to complete this operation Yahoo Messenger

Recently, I started to get this error message whenever I tried to use IM in yahoo messenger. As soon as I click on the contact to open the Instant Messenger, an error will popup with message that the “Not enough storage is available to complete this operation“. Here’s a screenshot of that error.

Yahoo Error Message

Yahoo Error Message

To fix this issue, you will need to reset your Internet Explorer settings and register the libraries again. Following are the steps to do so:

1. Exit Yahoo! Messenger. Right-click the tray icon and select “Exit.”
2. On your keyboard, press <Windows> + <R> to open the “Run” command.
3. Type in “inetcpl.cpl” and press Enter. This opens Internet Properties.
4. Select the “Advanced” tab, then click the “Reset…” button.
5. In the “Reset Internet Explorer Settings” dialog box, click the “Reset” button.
6. When the reset is complete, click “Close.”
7. Click the “Security” tab, then select “Trusted Sites.”
8. Click the “Sites” button.
9. Uncheck “Require server verification (https:) for all sites in this zone.”
10. In the “Add this website to the zone” field, copy and paste the following text:
*://*.yahoo.com/*

11. Click “Add,” then click “Close.”
12. Click “OK.”

Next, please download and install the latest version of Java Runtime Environment:

- http://java.sun.com/getjava/

Last, please register the Java and Windows Script installations:

1. On your keyboard, press <Windows> + <R> to open the “Run” command.
2. Type in “cmd” and click “OK.” This opens a Command Prompt.
3. Copy and paste each of the following commands into the Command Prompt. Press <Enter> on your keyboard after pasting each command.

regsvr32 vbscript.dll /s

regsvr32 jscript.dll /s

regsvr32 nusrmgr.cpl /s

regsvr32 mshtml.dll /s

regsvr32 themeui.dll /s

Restart your computer and your problem will be resolved now!!

Posted in windows | Tagged , , | Leave a comment

Enable dark background in Eclipse

I was looking around to find a good source which would allow me to control the background of the eclipse. I like black background with white text as foreground. Doing so in eclipse is not straightforward.

My System setup is:

  • Ubuntu 8.10
  • Eclipse Ganymede (3.4) with CDT

Follow the steps to get black background with white foreground for source code editing part of eclipse.

  1. Select Window -> Preferences -> C/C++ (language editor you need to change for) -> Editor. In the Appearance color options change the following
    • Matching brackets highlight (Color #FFA500)
    • Inactive code highlight (Color #302E2E)
    • Completion Proposal background (Color #000000)
    • Completion Proposal foreground (Color #FFFFFF)
    • Parameter Hint Background (Color #000000)
    • Parameter Hint Foreground (Color #FFFFFF)
    • Source Hover Background (Color #F5F5B5)
  2. Select Window -> Preferences -> C/C++ (language editor you need to change for) -> Editor -> Syntax Coloring
    • In the Code, change all the ones with black color to white and vice versa and leave the rest as they are.

This will give you the colors you want. I know its tedious but that’s the only way to do it at present.

Posted in linux | Tagged , | Leave a comment