How to Change the Nginx Server Name to Any Custom Name
Nginx (engine x) is a high-performance HTTP and reverse proxy web server that also provides IMAP/POP3/SMTP services. Xiaoz Blog also uses Nginx as its web server. To make it look more professional, let's modify the Nginx server name to something else.

Download Nginx
The official Nginx download address is: http://nginx.org/en/download.html. Find the latest stable version and download the source code locally.

Modify Nginx Source Code
After extracting the downloaded Nginx source code, you need to modify the following files. Here, we demonstrate changing the Nginx server name to XCDN.
File 1: src/core/nginx.h
#define NGINX_VER "nginx/" NGINX_VERSION
// Change to
#define NGINX_VER "xcdn/" NGINX_VERSION
#define NGINX_VAR "NGINX"
// Change to
#define NGINX_VAR "XCDN"
File 2: src/http/ngx_http_header_filter_module.c
static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
// Change to
static u_char ngx_http_server_string[] = "Server: xcdn" CRLF;
File 3: src/http/ngx_http_special_response.c
"<hr><center>nginx</center>" CRLF
// Change to
"<hr><center>xcdn</center>" CRLF
File 4: src/http/v2/ngx_http_v2_filter_module.c
"http2 output header: \"server: nginx\"");
// Change to
"http2 output header: \"server: xcdn\"");
By modifying the four files above, we have changed the Nginx server name to xcdn. If you do not want to locate and modify each file individually, you can also use the sed command to replace them directly:
# Execute rename operation
sed -i "s#\"NGINX\"#\"xcdn\"#" src/core/nginx.h
sed -i "s#\"nginx/\"#\"xcdn/\"#" src/core/nginx.h
sed -i "s#Server: nginx#Server: xcdn#" src/http/ngx_http_header_filter_module.c
sed -i "s#\"<hr><center>nginx<\/center>\"#\"<hr><center>xcdn<\/center>\"#" src/http/ngx_http_special_response.c
sed -i "s#server: nginx#server: xcdn#"
Test
After modification, you need to recompile the source code. This article does not describe how to compile Nginx; please search online for specific instructions. We can use the curl command to test if the modification was successful. Execute the test command curl -I https://blog.xiaoz.org. The returned result is as follows; you can see that the Server field has changed to xcdn.

Summary
Modifying the Nginx server name is not just for show; it can also provide a certain level of protection. Nginx has had vulnerabilities exposed in the past. After changing the server name, if bots scan and find that the server name is not Nginx, they may bypass the detection, achieving a deception effect.
This article references part of the content from: How to Modify the Default Internal Name of the Nginx Service to Any Name