Last updated on August 10th, 2020 at 03:05 am
mod_headers module allows you to set headers in Apache web server for your websites. It is useful for adding, modifying and removing request/response headers for your websites. Here’s how to enable mod_headers in Apache.
What is mod_headers
mod_headers is an Apache module that allows you to set headers for your Apache web server. It is useful for managing cache headers, cross-origin resource sharing (CORS) and even cookie management. By default, mod_headers is installed but disabled in many Apache versions. So you need to manually enable mod_headers. Otherwise, Apache will return ‘500: Internal Server Error’ when you try to change headers.
Bonus Read : How to Secure Apache with Let’s Encrypt
How to Enable mod_headers in Apache in Ubuntu/Debian
mod_headers is already enabled in CentOS/Redhat Linux systems. Here are the steps to enable mod_headers in Apache in Ubuntu/Debian. It is very easy to install any apache module in Ubuntu/Debian, thanks to a2enmod command. Here’s the syntax of a2enmod
$ sudo a2enmod <module_name>
Bonus Read : How to Set Cross Origin Resource Sharing Headers in Apache
1. Enable mod_headers in Ubuntu/Debian
Just open terminal and run the following command to enable mod_headers in Ubuntu/Debian linux.
$ sudo a2enmod mod_headers
2. Restart Apache Server
Restart Apache web server to Apply changes.
$ sudo service apache2 restart
Bonus Read : How to Install Apache mod_security
How to Check if mod_headers is enabled
You can check if mod_headers is enabled using apachectl -M command, which lists all the enabled modules for your Apache server. We use grep command on its output to look for headers module
$ apachectl -M | grep headers headers_module (shared)
Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!
Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI & software development.