Written by chenhow on June 30, 2009 – 11:32 pm - 14 views
By using .htaccess files, we can control access to our web content by allowing/blocking certain user or ip address to access it.
You may ask why we need that, if you can do the same by using options like “order, limit” to restrict ipaddresses and user actions in httpd.conf.
Fair enough, but there is some limitation.
Ok, let me give you a few secarios:
Let say you are a system administrator in ABC company and your company have a few branches over the world. All these branches located in Malaysia, Singapore, Taiwan and China. And each branches will have their own web directory to store all their documents.
Each branches office have a static ip and domain name
Malaysia 1.2.3.4 www.abc.my
Singapore 2.3.4.5 www.abc.sg
Taiwan 3.4.5.6 www.abc.tw
China 4.5.6.7 www.abc.cn
So, one day..
senarios 1:
You boss came to you and ask you to restrict all the web directory, that only allow all the branches can access to it, public user shouldn’t able to view or access it. Well, it will be easy , u just need to change the httpd.conf
httpd.conf
AllowOverride None Options AuthConfig # Allow use of the authorization directives
Order deny,allow
deny from all
allow 1.2.3.4
allow 2.3.4.5
allow 3.4.5.6
allow 4.5.6.7
But, in the same time , he wants to access all this directory from his house, which using dial up and doesnt have a fix address or ddns.
so what now?
Either you can ask him to apply a fix line or ask him to register dynamic dns.
But, ur boss definately wont like it.
so the best solution is to control the web content with valid username n passwd, another word ‘Web authentication’.
simply create a .htaccess in protect folder and add the following lines
Options Indexes#to enable directory listing AuthName “Password Protected by .htaccess“#Message that prompt when asking for username and password Authtype Basic
AuthUserFile /usr/local/apache2/passwd#password file location require user boss#username boss satisfy any#either u r using malaysia,china,singapore n taiwan ip or u have a valid username and password, then u can view and access this directory
if satisfy all, mean u must be one of the country ip and have to provide valid username n password in order to access.
generate username and password file
htpasswd -c /usr/local/apache2/passwd boss
-c is to create new passwd file, if u want to use back the existing password file
htpasswd /usr/local/apache2/passwd boss2
Is quite handy when you do not have the permission to change the httpd.conf file or restart the webserver.
Written by chenhow on May 18, 2009 – 2:24 pm - 157 views
To find duplicate IP, you can create a text file and putting all the IP addresses into it and seperate them with line break.
eg:
Create a text file called ip.txt [root@www ~]#touch ip.txt
Put all the ip into the file and save it [root@www ~]#vi ip.txt
192.168.1.22
192.167.1.22
192.168.1.23
192.168.1.23
192.168.1.70
192.168.1.88
192.168.1.89
192.168.1.40
192.168.1.63
192.168.1.77
192.168.1.79
192.168.1.78
192.168.1.11
192.168.1.82
192.168.1.24
192.168.1.91
192.168.1.64
192.168.1.94
192.168.1.21
192.168.1.96
192.168.1.95
192.168.1.69
“ip.txt” 138 lines, 2138 characters
Execute below command to find the duplicate ip [root@www ~]#sort ip.txt | uniq -d
#It will display all the duplicate IP 192.168.1.22
Written by chenhow on April 22, 2009 – 11:29 pm - 146 views
Personally I think this joke is quite funny, so want to share with you guys. Enjoy!
When Dr. Mahathir was Prime Minister of Malaysia ...
One lousy day in the middle of ...
Written by chenhow on April 18, 2009 – 12:01 am - 173 views
5 days ago my hosting account has been suspended due to high number of CPU/Memory usage.
After doing some troubleshooting and checking all the logs. I found that recently got a ...
Written by chenhow on April 5, 2009 – 4:08 am - 443 views
Google-blog-converters-appengine is a converter to/from various blog formats like wordpress2blogger, blogger2wordpress and etc.
Let's take an example, says we are going to convert blog post from wordpress to blogger with google-blog-convertes-appengine.
Steps:
1. ...
Written by chenhow on April 5, 2009 – 2:56 am - 182 views
Simply goto the Accounts tab from Gmail settings page and click on "Add a mail account you own". Type the Hotmail address and use the following settings:
Later you will be ...
Written by chenhow on April 5, 2009 – 1:01 am - 681 views
Conky is a light weight system monitor that uses to display system information on your Desktop. You can display various information like CPU, memory, network, hard disk capacity and etc ...
In this blog, I'll share my knowledge, discovery and experience related to IT and administering Linux. Most articles on this site are related to News, Review, Tips, My Life journal and many more. To find out more about me, click Here!