Apache Modules

Apache is one of the most popular web server, which is used to host websites and web applications. More than half of all web sites are served by Apache, and this server is perfect for large and small projects.

The Apache web server is very flexible and customizable. Many functions are not included in the kernel, and is made in the form of modules. The Apache modules help to optimize the performance of a web server, to make it safer to control the additional features and to obtain more detailed information about queries. You this article we will look at how to see list of modules, what they are, how to configure them, and will bring the main and the most useful Apache modules.

What is the Apache module?

The Apache module allows you to extend the functionality of web servers, we already knew that. All modules are designed as dynamic-link libraries with the extension *.so. They are in a separate folder for modules and can be installed both manually and with the help of the package Manager of the distribution.

Also, to activate the module, you must connect it in the configuration program, usually in the same settings and specific settings for the module. Next, we’ll talk more about this.

How to enable Apache?

As I said, the installation of apache modules can be run in different ways, for example, by using package Manager or even manually compile. But to download them, Apache needs to know where the dynamic library and main settings to properly load the module.

Usually in the Apache configuration folder, e.g. /etc/apache/mods-available is a file module where it is imported to a library and specify the settings. Thus, to enable the plugin it will be sufficient to transfer a file with its configuration in the directory from which configuration is loaded when you start Apache. For example, in /etc/apache2/mods-enabled. First, look at the list of apache modules:

sudo apachectl -M

So see the apache modules you can in Ubuntu and derivative distributions, on other systems the file locations and commands may vary, but the essence is the same, the address library module should be included in the basic configuration, no matter in what way. Ubuntu also has a utility to automatically copy the files where you want when you activate the module, it is a2enmod. For example, enable the rewrite module:

sudo a2enmod rewrite

Or off:install apache modules

sudo a2dismod rewrite

Now consider the main Apache modules that you might need.

Best Apache modules

1. PageSpeed

The PageSpeed module allows you to optimize the performance of web servers and accelerate content download. It supports data compression, caching, resizing files and removing extra spaces and characters from files. The module made by Google to increase the speed of downloading content. To install the module in Ubuntu, run the following commands:

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
$ sudo dpkg-i mod-pagespeed-*.deb
$ sudo apt -f install
$ sudo systemctl restart apache2

We downloaded the latest version from the official site, then installed the package, its dependencies and restart your web server. If the dpkg command will issue an error resolving dependencies, it’s OK, it will be fixed with a call to apt. The module will automatically be activated after installation. You can see the list of Apache modules to make sure the module was activated:

sudo apachectl -M | grep pagespeed

The configuration file is located at /etc/apache2/mods-available/pagespeed.conf here you can set various additional settings.

2. Security

The mod_security module adds an additional layer of protection by using the deviation of certain types of traffic based on rules and filters. Is a software firewall that allows you to protect your web server against certain vulnerabilities and problems. To install this module from the official repositories:

sudo apt install libapache2-modsecurity

Then the module you want to activate, e.g. using a2enmod:

sudo a2enmod mod-security

The configuration file is in the folder /etc/apache2/mod-security.conf, it specifies the symbolic link from /etc/modsecurity. Set up rules depending on your needs and the features of the site. Then activate the protection by setting the SecRuleEngine from DetectionOnly to on:

SecRuleEngine On

Don’t forget to restart the web server for residual activation of the module.

3. Status

This is one of the most useful and simple modules, which is installed by default with Apache. Using mod_status, you can estimate the load on the server, as well as the number of queries. The configuration file is in the folder /etc/apache2/mods-available:

sudo vi /etc/apache2/mods-available/status.conf

Here, in the section Locaction need to add a line Allow from your IP address from which access to the statistics:

<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from waste
</Location>

Then save changes and restart Apache. Now, to look at the statistics will suffice to open in the browser:

waste/server-status

Here you will find a lot of useful information about the load on the server.

4. Spamhaus

Spamhaus is a module that allows you to block requests from IP addresses that are considered the addresses of the hackers. You can install the module spamhaus from the official repositories with the command:

sudo apt install libapache2-mod-spamhaus

The settings file is located at /etc/apache2/mods-available/mod_spamhaus.conf. You can filter the modules according to various criteria, for example, MS_METHODS allows you to block IP addresses that were seen in the http flood. You can also configure a whitelist of IP addresses. After installing the module you want to activate:

sudo a2enmod mod-spamhauspamhaus-drop.git
$ sudo systemctl restart apache2

5. Rewrite

This is one of the most popular and most used Apache modules, it is used most websites. It allows you to generate easily readable URLS for documents, to perform redirects and different ways to convert the content of requests. Configure the rewrite module is dealt with in a separate article. The module is installed by default, but some distributions you need to activate it:

sudo a2enmod rewrite
$ sudo systemctl restart apache2

All settings are performed using the httaccess file, although you can use to specify these settings anywhere.

Insights

In this article we reviewed the main Apache modules which you can use. But this is not a complete list. Constantly creating new modules that allow to expand opportunities of the program and to change its default behavior. But keep in mind that the more code you add to the server, the greater the expenditure of resources and the more likely that the code has critical error. Choose only well-tested modules that are used by a large number of users.

Source: losst.ru

(Visited 94 times, 1 visits today)