• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

Apache HTTP server – most commonly used containers (special configuration directives)

By admin

Apache containers are special configuration directives that group other directives. The containers use XML-style tags, meaning that the beginning of a container is <name> and the end is </name>. An index of all the container directives is available at http://httpd.apache.org/docs/current/sections.html. The following are examples of containers:

<Directory directory-path>

This container applies directives to directories within directory-path. The example applies Deny, Allow, and AllowOverride directives to all files and directories within the /var/www/html/test directory hierarchy. Indenting is for readability only.

<Directory /var/www/html/test>
      Deny from all
      Allow from 192.168.2.
      AllowOverride All
</Directory>

The AllowOverride directive in this container specifies classes of directives that are allowed in .htaccess files. The .htaccess files are other configuration files that typically contain user authentication directives. The ALL argument to AllowOverride means that all classes of directives are allowed in the .htaccess files. There are classes of directives that control authorization, control client access, control directory indexing, and others.

<IfModule [!]module-name>

This container applies directives if module-name is loaded. With the optional exclamation point, Apache does the inverse; that is, it sets the directives in the container if the module-name is not loaded. An example is as follows:

<IfModule mod_userdir.c>
      UserDir disabled
</IfModule>

<Limit method [method] …>

This container limits access control directives to specified methods. An HTTP method specifies actions to perform on a Uniform Resource Identifier (URI). Examples of methods are GET (the default), PUT, POST, and OPTIONS. The following example disables HTTP uploads (PUT) from systems that are not in the example.com domain:

<Limit PUT>
      Order deny,allow
      Deny from all
      Allow from .example.com
</Limit>

<LimitExcept method [method] …>

This container is the opposite of the Limit container in that it limits access control directives to
all except specified methods. The following example uses the LimitExcept container but also illustrates that containers can be nested. This example controls access to UserDir directories by restricting these directories to be read-only:

<Directory /home/*/public_html>
      AllowOverride FileInfo AuthConfig Limit
      Options MultiViews Indexes SymLinksIfOwnerMatch \
      IncludesNoExec
      <Limit GET POST OPTIONS>
           Order allow,deny
           Allow from all
      </Limit>
      <LimitExcept GET POST OPTIONS>
           Order deny,allow
           Deny from all
      </LimitExcept>
</Directory>

The Options directive controls server features by directory. Some of these are described:

  • MultiViews: Allows a page to be displayed in different languages, for example
  • Indexes: Generates a directory listing if the DirectoryIndex directive is not set
  • SymLinksIfOwnerMatch: Follows symbolic links if the file or directory being pointed to has the same owner as the link

Filed Under: CentOS/RHEL 7, Linux

Some more articles you might also be interested in …

  1. Linux OS Service ‘yum-updatesd’
  2. How to enable IPv6 on CentOS / RHEL 6
  3. CentOS / RHEL : How to Disable and Blacklist Linux Kernel Module to prevent it from loading automatically
  4. CentOS / RHEL 7 : How to install and configure telnet
  5. How To Disable Ksplice Service on OEL
  6. How to recover from a corrupt RPM database (rebuilding an RPM database)
  7. Understanding the /etc/inittab File in Linux
  8. Changing the IPset rules from IPtables to Firewalld in CentOS/RHEL 7
  9. Linux “rm” Command Examples
  10. CentOS / RHEL : How to Set up SFTP to Chroot Jail only for Specific Group

You May Also Like

Primary Sidebar

Recent Posts

  • How to Pause and Resume Docker Containers
  • How to find docker storage device and its size (device mapper storage driver)
  • Understanding “docker stats” Command Output
  • ‘docker images’ command error – “Permission Denied”
  • Docker Basics – Expose ports, port binding and docker link
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary