How to install and tune Nginx

WBOY
Release: 2023-05-20 09:55:20
forward
1357 people have browsed it


How to install and tune Nginx
##Nginx optimization before compilation

[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/
Copy after login

Optimization before compilation is mainly used to modify the program name, 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 OK
Server: nginx/1.10.1 #我们目标是将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
Copy after login

Purpose to change the name and version number of the source code hidden 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 modify

[root@linuxprobe nginx-1.10.1]# vim +49 src/http/ngx_http_header_filter_module.c
Copy after login

Modify the connection field in the HTTP header information to prevent the specific version number from being echoed

Extension: general http Header fields

General header fields include header fields supported by both request and response messages. Common header fields include Cache-Control, Connection, Date, Pragma, Transfer-Encoding, Upgrade, and Via. If the common header field is extended, both parties need to support this extension. If there is an unsupported general header field, it will generally be treated as an entity header field. Some devices or software are able to obtain connection information, while others are not. If you want to completely hide it, you must do comprehensive confidentiality

static char ngx_http_server_string[] = "Server: LinuxprobeWeb" CRLF;

[root@linuxprobe nginx-1.10.1]# vim +29 src/http/ngx_http_special_response.c
Copy after login

Defines the return of http error codes

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

static u_char ngx_http_error_full_tail[] ="" NGINX_VER "" CRLF"
Copy after login

The above is the detailed content of How to install and tune Nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template