nginx編譯前的優(yōu)化
[root@linuxprobe?~]#?wget?http://nginx.org/download/nginx-1.10.1.tar.gz[root@linuxprobe?~]#?tar?xvf?nginx-1.10.1.tar.gz?-C?/usr/local/src/[root@linuxprobe?~]#?cd?/usr/local/src/nginx-1.10.1/
編譯前的優(yōu)化主要是用來(lái)修改程序名等等,例如:
[root@linuxprobe?nginx-1.10.1]#?curl?-I?http://www.baidu.com…… Server:?bfe/1.0.8.14 …… [root@linuxprobe?nginx-1.10.1]#?curl?-I?http://www.sina.com.cn…… Server:?nginx …… [root@linuxprobe?nginx-1.10.1]#?curl?-I?https://www.linuxprobe.comHTTP/1.1?200?OK Server:?nginx/1.10.1?#我們目標(biāo)是將nginx更改名字Content-Type:?text/html;?charset=UTF-8 Connection:?keep-alive X-Powered-By:?PHP/5.6.29 Set-Cookie:?PHPSESSID=smm0i6u4f9v7bj0gove79ja1g7;?path=/ Cache-Control:?no-cache date:?Mon,?07?Seq?2016?06:09:11?GMT [root@linuxprobe?nginx-1.10.1]#?vim?src/core/nginx.h
目的更改源碼隱藏軟件名稱和版本號(hào)
#define nginx_version “nginx_stable” #此行修改的是你想要的版本號(hào)
#define NGINX_VER “l(fā)inuxprobe/” NGINX_VERSION #此行修改的是你想修改的軟件名稱
[root@linuxprobe?nginx-1.10.1]#?vim?+49?src/http/ngx_http_header_filter_module.c
修改HTTP頭信息中的connection字段,防止回顯具體版本號(hào)
拓展:通用http頭域
通用頭域包含請(qǐng)求和響應(yīng)消息都支持的頭域,通用頭域包含Cache-Control、 Connection、Date、Pragma、Transfer-Encoding、Upgrade、Via。如果通用頭域被擴(kuò)展,雙方都需要支持此擴(kuò)展。如果存在不支持的通用頭域,一般會(huì)當(dāng)作實(shí)體頭域來(lái)處理。一些設(shè)備或軟件能夠獲取連接信息,而另一些則不能,如果要完全隱藏,就必須做全面的保密
Static char ngx_http_server_string[] = “Server: LinuxprobeWeb” CRLF;
[root@linuxprobe?nginx-1.10.1]#?vim?+29?src/http/ngx_http_special_response.c
定義了http錯(cuò)誤碼的返回
有時(shí)候我們頁(yè)面程序出現(xiàn)錯(cuò)誤,Nginx會(huì)代我們返回相應(yīng)的錯(cuò)誤代碼,回顯的時(shí)候,會(huì)帶上nginx和版本號(hào),我們把他隱藏起來(lái)
static?u_char?ngx_http_error_full_tail[]?=""?NGINX_VER?""?CRLF"
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END