HTTP: Configure private directories.

Share this link

Install the “Web server” package group:

# yum groupinstall -y "Web server"

There are several ways to restrict access to directories:

1) host-based private directories
To only allow test.example.com (add the name/IP address in the /etc/hosts file if necessary) to access a specific directory (here private), edit the /etc/httpd/conf/httpd.conf file and type:

<Directory "/var/www/html/private">
AllowOverride None
Options None
Order allow,deny
Allow from test.example.com
</Directory>

Check the configuration file:

# service httpd configtest

Create the private directory:

# mkdir -p /var/www/html/private
# restorecon -R /var/www/html/private

2) user-based private directories
To only allow me to access a specific directory (here private), edit the /etc/httpd/conf/httpd.conf file and type:

<Directory "/var/www/html/private">
AuthType Basic
AuthName "Password protected area"
AuthUserFile /etc/httpd/conf/passwd
Require user me
</Directory>

Check the configuration file:

# service httpd configtest

Create the private directory:

# mkdir -p /var/www/html/private
# restorecon -R /var/www/html/private

Create the passwd file and store me’s password:

# htpasswd -c /etc/httpd/conf/passwd me

Note: the .htpasswd file can locally be used instead of the httpd.conf file in 1) and 2) for the same purpose.

Whatever the option chosen, add a new rule to the firewall:

# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT

Save the firewall configuration:

# service iptables save

Activate the httpd service at boot:

# chkconfig httpd on

Start the httpd service:

# service httpd start

Check the httpd service:

# yum install -y elinks
# elinks http://localhost/private
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Leave a Reply

Be the First to Comment!

Notify of
wpDiscuz

RHCSA7: Task of the day

Allowed time: 10 minutes.
Archive and compress the content of the /opt directory (create files if none exists).
Uncompress and unarchive the resulting file in /root

RHCE7: Task of the day

Allowed time: 10 minutes.
Configure a system to forward all email to a central mail server at 192.168.1.1 (change the IP address accordingly).

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...