linux_wiki:configure_access_restrictions_on_directories

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:configure_access_restrictions_on_directories [2018/04/07 23:27]
billdozor [Restrict Access]
linux_wiki:configure_access_restrictions_on_directories [2019/05/25 23:50] (current)
Line 12: Line 12:
   * server1.example.com (192.168.1.150) -> Perform all connectivity tests from here   * server1.example.com (192.168.1.150) -> Perform all connectivity tests from here
   * server2.example.com (192.168.1.151) -> Install Apache Web Server here   * server2.example.com (192.168.1.151) -> Install Apache Web Server here
 +
 +**Previous Sections Completed**
 +  * [[linux_wiki:network_services_overview_apache_web_server|Install/Configure]]
 +    * Except leave listening on port 80/tcp
 +  * [[linux_wiki:configure_a_virtual_host|Virtual Host Config]]
  
 ---- ----
Line 27: Line 32:
   ErrorLog logs/redsite-error_log   ErrorLog logs/redsite-error_log
   CustomLog logs/redsite-access_log combined   CustomLog logs/redsite-access_log combined
 +  
 +  <Directory "/data/redsite">
 +    Options None
 +    AllowOverride None
 +    Require all granted
 +  </Directory>
 </VirtualHost> </VirtualHost>
 </code> </code>
Line 68: Line 79:
  
 \\ \\
-Create a private file+Create a private index file
 <code bash> <code bash>
-echo "This is for certain people only." > /data/redsite/private/secret.txt+echo "This is for certain people to view only." > /data/redsite/private/index.html
 </code> </code>
  
Line 88: Line 99:
 restorecon -Rv /data/redsite/ restorecon -Rv /data/redsite/
 </code> </code>
 +  * Reminder: man semanage-fcontext  (EXAMPLE at the bottom)
  
 ===== Restrict Access ===== ===== Restrict Access =====
  
-Edit the vhosts.conf file and add the Directory part in the redsite virtualhost+**Help**: Available if you installed 'httpd-manual'<code bash>elinks /usr/share/httpd/manual/howto/auth.html</code> 
 + 
 +\\ 
 +Create password for the user 
 +<code bash> 
 +htpasswd -c /etc/httpd/conf/userdb user1 
 +</code> 
 +  * Prompted for a password 
 + 
 +\\ 
 +Edit the vhosts.conf file and add this additional Directory part in the redsite virtualhost
 <code bash>vim /etc/httpd/conf.d/vhosts.conf <code bash>vim /etc/httpd/conf.d/vhosts.conf
 +
 <VirtualHost *:80> <VirtualHost *:80>
   ServerName redsite.example.com   ServerName redsite.example.com
   DocumentRoot /data/redsite   DocumentRoot /data/redsite
-  ErrorLog logs/redsite-error_log +  #....SNIP....#
-  CustomLog logs/redsite-access_log combined +
  
   <Directory "/data/redsite/private">   <Directory "/data/redsite/private">
     AuthType Basic     AuthType Basic
     AuthName "Restricted Area"     AuthName "Restricted Area"
-    AuthUserFile "/etc/httpd/conf/usersdb"+    AuthUserFile "/etc/httpd/conf/userdb"
     Require valid-user     Require valid-user
   </Directory>   </Directory>
 </VirtualHost> </VirtualHost>
-</code> 
- 
-\\ 
-Create password for the user 
-<code bash> 
-htpasswd -c /etc/httpd/conf/usersdb user1 
-</code> 
-  * Prompted for a password 
- 
-\\ 
-Change permissions on the userdb file 
-<code bash> 
-chown :apache /etc/httpd/conf/.userdb 
-chmod 640 /etc/httpd/conf/.userdb 
 </code> </code>
  
Line 132: Line 139:
 Visit restricted directory Visit restricted directory
 <code bash> <code bash>
-elinks http://testsite.example.com/user1dir+elinks http://redsite.example.com/private/
 </code> </code>
   * elinks may need to be installed first (yum install elinks)   * elinks may need to be installed first (yum install elinks)
  • linux_wiki/configure_access_restrictions_on_directories.1523158041.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)