Nginx _ modify the Server value in the Web Server Header (Header), nginxheader

Source: Internet
Author: User

Nginx _ modify the Server value in the Web Server Header (Header) [convert], nginxheader

Http://blog.rekfan.com /? P = 122

When hackers attack a website, they often need to know the server architecture, website architecture, and other information. Once they understand this information, they will know where the website is weak!
In order not to let the other party know the real environment of their webserver, we can pretend to hide our real server environment. Although security protection cannot be 100%, it will at least make the other Party feel overwhelmed! @_@''

I. Windows Environment

Modify nginx server Information

1. Go to the nginx installation directory and use a text editor to edit fastcgi. conf In the conf directory.

Fastcgi_param SERVER_SOFTWARE nginx/$ nginx_version;

2. Use a text editor to edit fastcgi_params In the conf directory

Fastcgi_param SERVER_SOFTWARE nginx/$ nginx_version;

3. # service nginx restart # restart nginx

Hide nginx server Information

1. Go to the nginx installation directory and use a text editor to edit nginx. conf under the conf directory

# Add the following content to http:

Server_tokens off;

2. # service nginx restart # restart nginx

Ii. In Linux

Similar to windows operations, the file name may be slightly different. However, after I change the file name, Nginx is displayed, and src/core/nginx is compiled based on changes made on the Internet. h. Let's take a look at the header information before the change:

[Root @ REKFAN-Server/] # curl-I http://blog.rekfan.com
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 02 Nov 2012 15:25:42 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 01 Nov 2012 18:47:51 GMT
Connection: keep-alive
ETag: "5092c3d7-264"
Accept-Ranges: bytes

The modified src/core/nginx. h code is as follows:

/*
* Copyright (C) Igor Sysoev
* Copyright (C) Nginx, Inc.
* Http://blog.rekfan.com /? P = 122
*/

# Ifndef _ NGINX_H_INCLUDED _
# Define _ NGINX_H_INCLUDED _

# Define nginx_version 1003008
# Define NGINX_VERSION "1.3.8"
# Define NGINX_VER"REKFAN/"NGINX_VERSION

# Define NGINX_VAR"REKFAN"
# Define NGX_OLDPID_EXT ". oldbin"

# Endif/* _ NGINX_H_INCLUDED _*/

Compile Nginx and check whether the result header information remains unchanged!

Finally, find another post to change the src/http/ngx_http_header_filter_module.c file!

Find the following two rows:
Static char ngx_http_server_string [] = "Server:Nginx"CRLF;
Static char ngx_http_server_full_string [] = "Server :"NGINX_VERCRLF;
Modify it:
Static char ngx_http_server_string [] = "Server:REKFAN"CRLF;
Static char ngx_http_server_full_string [] = "Server:REKFAN/1.0"CRLF;

Set the aboveRedModify the information you want to display. Re-compile and restart Nginx!

Re-view the header information:
[Root @ REKFAN-Server/] # curl-I http://blog.rekfan.com
HTTP/1.1 200 OK
Server: REKFAN
Date: Fri, 02 Nov 2012 15:30:28 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 01 Nov 2012 18:47:51 GMT
Connection: keep-alive
ETag: "5092c3d7-264"
Accept-Ranges: bytes

Later we found that when we added the server_tokens off; parameter, the value in src/http/ngx_http_header_filter_module.c was called.
If this parameter is not added, the version number indicates the value in src/core/nginx. h. Therefore, we try to modify the value in both places during modification!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.