Development
Amz 2023 Nginxheader

Nginx Header Module Installation Guide

This guide explains how to install and configure the Headers More Nginx Module, which allows you to modify or remove response headers (e.g., hiding the Server header).


1. Install Build Tools

sudo yum groupinstall "Development Tools" -y
sudo yum install pcre pcre-devel zlib zlib-devel openssl openssl-devel wget gcc make git -y

2. Get Current Nginx Version

nginx -v
NGINX_VERSION=$(nginx -v 2>&1 | awk -F/ '{print $2}')
echo "Detected Nginx version: $NGINX_VERSION"

3. Download and Extract Nginx Source

cd /usr/local/src
wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz
tar -xvzf nginx-$NGINX_VERSION.tar.gz
cd nginx-$NGINX_VERSION

4. Download Headers More Module

git clone https://github.com/openresty/headers-more-nginx-module.git

5. Build the Module

./configure --with-compat --add-dynamic-module=./headers-more-nginx-module
make modules
ls -la objs/ngx_http_headers_more_filter_module.so

6. Install the Module

sudo mv objs/ngx_http_headers_more_filter_module.so /usr/share/nginx/modules/

7. Configure Nginx

Edit nginx.conf:

load_module modules/ngx_http_headers_more_filter_module.so;
 
http {
    server_tokens off;              # Hides version info
    more_clear_headers Server;      # Removes the Server header entirely
}

8. Test and Restart

nginx -t
sudo systemctl restart nginx

9. Verification

  • Run curl -I http://yourdomain.com
  • The Server header should be hidden or modified as per your config.

🧙 AI Wizard - Instant Page Insights

Click the button below to analyze this page.
Get an AI-generated summary and key insights in seconds.
Powered by Perplexity AI!