Operations 6 min read

Hide Nginx Version Info and Optimize Server Performance

This guide explains how to conceal Nginx version headers, modify source files to remove software identifiers, change default users, tune worker processes, adjust connection limits, enable efficient file transfer, and set appropriate timeouts for a more secure and performant web server.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Hide Nginx Version Info and Optimize Server Performance

Hide Nginx Header Version Number

1. Check current version – see the screenshot showing the version header.

2. Hide the version number

Add server_tokens off; inside the http block of the Nginx configuration, or within the server or location blocks as needed.

After reloading, the error page no longer displays the version number.

Modify Source to Hide Software Name and Version

Before compiling Nginx, edit the source files:

1. Change version string – edit nginx-1.3.4/src/core/nginx.h and replace the version definition.

2. Update header filter module – modify nginx-1.6.12/src/http/ngx_http_header_filter_module.c to replace the server header string.

3. Edit special response file – modify ngx_http_special_response.c to change default error page headers.

Change Default Nginx User and Group (Worker Process Optimization)

1. Check default configuration – by default Nginx runs as nobody for both user and group.

2. Create a dedicated Nginx user – add a system user such as nginx or a custom name.

3. Update nginx.conf – set the user directive at the top of the configuration file to the new user.

4. Run worker processes as a non‑root user – lower the privileges of the master process and avoid using privileged port 80; use a front‑end reverse proxy instead.

Configure Nginx Worker Process Count

Nginx consists of a master process and multiple worker processes. Set the number of workers to match the CPU core count or double it, then edit the first line of nginx.conf accordingly.

CPU Affinity Optimization

Assign worker processes to specific CPU cores to improve cache locality. Example configurations are provided for four‑core and eight‑core CPUs.

Nginx Event Model Optimization

Choose the appropriate event handling model based on the operating system: epoll for Linux, kqueue for FreeBSD, /dev/poll for Solaris, etc. For CentOS 6.5, set the model to epoll using the use epoll; directive.

Adjust Max Client Connections per Worker

Set worker_connections to define the maximum number of simultaneous connections a single worker can handle. The overall limit is worker_processes * worker_connections.

Configure Max Open Files for Workers

Set the worker_rlimit_nofile directive to match the system's ulimit -Hn value, ensuring the limit reflects the server’s capacity.

Enable Efficient File Transfer

Add tcp_nopush in the http block to combine HTTP response headers with the start of the file, reducing the number of network packets.

Set Connection Timeout

Configure appropriate timeout values in the http block to protect server resources; short‑lived connections are recommended for PHP sites, while longer timeouts suit Java applications.

Upload File Size Limits (Dynamic Applications)

Adjust the client_max_body_size directive in the http block to control the maximum allowed upload size for dynamic applications.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceConfigurationNGINXserver optimization
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.