Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and tune Nginx

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install and optimize Nginx". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to install and tune Nginx".

Nginx pre-compilation optimization [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/ pre-compilation optimization is mainly used to modify program names, etc. For example: [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 OKServer: nginx/1.10.1 # our goal is to change the name of nginx Content-Type: text/html; charset=UTF-8Connection: keep-aliveX-Powered-By: PHP/5.6.29Set-Cookie: PHPSESSID=smm0i6u4f9v7bj0gove79ja1g7 Path=/Cache-Control: no-cacheDate: Mon, 07 Seq 2016 06:09:11 GMT [root@linuxprobe nginx-1.10.1] # vim src/core/nginx.h to change the name and version number of the source code hiding software

# define NGINX_VERSION "nginx_stable" # this line modifies the version number you want

# define NGINX_VER "linuxprobe/" NGINX_VERSION # this line modifies the name of the software you want to change

[root@linuxprobe nginx-1.10.1] # vim + 49 src/http/ngx_http_header_filter_module.c modifies the connection field in the HTTP header to prevent specific version numbers from being echoed

Expansion: general http header domain

The common header domain contains the header domain supported by both request and response messages, and the common header domain includes Cache-Control, Connection, Date, Pragma, Transfer-Encoding, Upgrade, and Via. The extension of the universal header domain requires that both sides of the communication support this extension, and if there is an unsupported universal header domain, it will generally be treated as an entity header domain. That is to say, some devices, or software, can get connection, but some can't, so you have to hide it thoroughly!

Static char ngx_http_server_string [] = "Server: LinuxprobeWeb" CRLF

[root@linuxprobe nginx-1.10.1] # vim + 29 src/http/ngx_http_special_response.c defines the return of http error codes

Sometimes when there is an error in our page program, Nginx will return the corresponding error code on our behalf. When it is echoed, it will be returned with nginx and version number, and we will hide it.

Static u_char ngx_http_error_full_tail [] = "NGINX_VER"CRLF" Thank you for your reading, the above is the content of "how to install and optimize Nginx". After the study of this article, I believe you have a deeper understanding of how to install and tune Nginx, and the specific use needs to be verified in practice. here, the editor will push more articles on related knowledge points, welcome to follow us!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report