cat << EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true

[Install]
WantedBy=multi-user.target
EOF

修改相关配置文件

vi /usr/local/nginx/conf/nginx.conf

http模块加入 server_tokens   off;

Hide_Nginx_Version_Number_A

vi /usr/local/nginx/conf/fastcgi.conf

fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

改为

fastcgi_param  SERVER_SOFTWARE    nginx;

Hide_Nginx_Version_Number_B

/usr/local/nginx/sbin/nginx -t

/usr/local/nginx/sbin/nginx -s reload

修改前后对比

Hide_Nginx_Version_Number_C

Hide_Nginx_Version_Number_D

Windows

修改 C:\Windows\System32\Drivers\etc\hosts

新增【IP 域名】,多个需回车换行,例:

127.0.0.1 www.baidu.com

Ctrl + S保存,打开无痕浏览器,F12进行测试

Linux

修改 /etc/hosts

新增【IP 域名】,多个需回车换行,例:

127.0.0.1 www.baidu.com

:wq保存,curl进行测试