Sunday, April 24, 2016

Setting up Authenticated Web Servers

  • install a manual for examples and syntax
    • yum install -y httpd-manual
    • httpd://localhost/manual
  • Set up Basic Authentication
    • htpasswd -c /etc/httpd/htpasswd erick
    • type the passwword
  • Create directory
    • mkdir -p /srv/web/restricted
  • Change the selinux security label of DocumentRoot.
    • semanage fcontext -a -t httpd_sys_content_t "/srv/web(/.*)?"
    • restorecon -R -v /srv/web
  • Create index.html
    • vim /srv/web/restricted/index.html
  • Create virtual host
    • vim /etc/httpd/conf.d/restricted.conf

<Directory /srv/web/restricted>

    AuthType Basic
    AuthName "Restricted Files"
    AuthBasicProvider file
    AuthUserFile /etc/httpd/htpasswd
    Require user erick
</Directory>

<VirtualHost *:80>
    ServerAdmin root@restricted.example.com
    DocumentRoot "/srv/web/restricted"
    ServerName restricted.example.com
    ServerAlias www.restricted.example.com
    ErrorLog "logs/restricted-error_log"
    CustomLog "logs/restricted-access_log" combined
</VirtualHost>

  • Restart httpd
    • systemctl restart httpd

No comments:

Post a Comment