Wednesday 27 January 2016

How to Secure Specific URL in Apache

This article will help you secure specific url in Apache. For example our site has an url likehttp://tecadmin.net/admin/” and we need that only the authorized users or ips can access/admin/ section.

Setup IP Based Restriction on Specific URL

Step 1: Edit apache configuration file and add below entry in websites virtual host.
<Location /admin>
Order deny,allow
Deny from all
Allow from 192.168.10.111
Allow from 111.222.333.444
</Location>
Step 2: Save Apache configuration file and restart apache service.
# service httpd restart
Step 3: Try to access your site from any other ip. Also check from given ip in configuration file.

Setup User Authentication on Specific URL

Step 1: Edit apache configuration file and add below entry in website virtual host.
<Location /admin>
AuthUserFile /var/www/htpasswd/.htpasswd
AuthName "Password Protected Area"
AuthType Basic
Require valid-user
</Location>
Step 2: Create htpasswd file using below command.
# htpasswd -cm /var/www/htpasswd/.htpasswd myuser

New password:
Re-type new password:
Adding password for user myuser
Step 3:
Restart apache and access your site url. It will prompt for login details.
# service httpd restart
Thanks for using this article, I hope this article fulfill your needs. Click here to read more details about apache location directive.

Monday 25 January 2016

Install redis 3 on Debian 7

The easiest way to install a Redis server is to just run
apt-get install redis-server -y  
Unfortunately, this will only install version 2.8.17 which doesn't have the features in 3.0+.

Manually Install Redis 3+

Redis 3.0 introduces Redis Cluster, a distributed implementation of Redis with automatic data sharding and fault tolerance, important speed improvements under certain workloads, improved AOF rewriting, and more.
Here's how to manually install the latest version.
apt-get update
apt-get install build-essential -y

wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable
make
apt-get install tcl8.5 -y
# optionally run "make test" to check everything is ok
make install
Redis is now installed. To configure redis to run as a background daemon run a script that came bundled with the files
cd utils
bash ./install_server.sh
You will be prompted for configuration values, but you may want to just press return to accept the defaults.

Extra

Check Version

redis-server --version  

Manage The Service

service redis_6379 [start | stop | restart]  

Start the Management Console

redis-cli