Documentation Index
Fetch the complete documentation index at: https://docs.ahmadraza.in/llms.txt
Use this file to discover all available pages before exploring further.
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).
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
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/
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.