本文共 1838 字,大约阅读时间需要 6 分钟。
1)首先要下载nginx包这里以1.12.2为例;
2)安装nginx所需的支持包
3)创建nginx用户
4)解压nginx并配置
①vi src/core/nginx.h 13行 #define nginx_version 1010002 #define NGINX_VERSION "6.12.62" #此行修改的是你想要的版本号 #define NGINX_VER "MidServer/" NGINX_VERSION #此行修改的是你想修改的软件名称 ![](https://s1.51cto.com/images/blog/201901/08/dcb7f60989243494cb5e2351d441433f.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=) ②# vim src/http/ngx_http_special_response.c 29行 #static u_char ngx_http_error_tail[] = "
MidServer " CRLF "" CRLF "" CRLF ![](https://s1.51cto.com/images/blog/201901/08/d987ac49b6e40902f928e25f5d6f6cb5.jpg?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
5)yum -y install pcre openssl
cd nginx-1.12.2/ # ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx \
--with-file-aio \
--with-http_ssl_module \--ith-http_realip_module \--ith-http_sub_module \--ith-http_gzip_static_module \--with-http_stub_status_module \--with-pcremake && make install
6)安装完后我们启动服务
测试是否隐藏了版本和软件名
# curl -I 192.168.80.100
HTTP/1.1 200 OKServer: MidServer/6.12.62Date: Tue, 08 Jan 2019 07:36:11 GMTContent-Type: text/htmlContent-Length: 612Last-Modified: Tue, 08 Jan 2019 07:34:45 GMTConnection: keep-aliveETag: "5c345295-264"Accept-Ranges: bytes
我们拿浏览器进行错误代码测试:
转载于:https://blog.51cto.com/python20101030/2340180