Nginx-隐藏版本号

2022/1/10 7:05:04

本文主要是介绍Nginx-隐藏版本号,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

配置文件隐藏版本号

Syntax:    server_tokens on | off | build | string;
Default:    
server_tokens on;
Context:    http, server, location

编译安装隐藏版本号

]# vim ~/nginx-1.16.1/src/core/nginx.h
/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) Nginx, Inc.
 */


#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_


#define nginx_version      1016001
#define NGINX_VERSION      "1.0"  //版本号
#define NGINX_VER          "nicai/" NGINX_VERSION   //服务器名称

#ifdef NGX_BUILD
#define NGINX_VER_BUILD    NGINX_VER " (" NGX_BUILD ")"
#else
#define NGINX_VER_BUILD    NGINX_VER
#endif

#define NGINX_VAR          "NGINX"
#define NGX_OLDPID_EXT     ".oldbin"


#endif /* _NGINX_H_INCLUDED_ */

重新编译后测试

]# curl http://www.magedu.net/about/index1 -i
HTTP/1.1 200 OK
Server: nicai/1.0
Date: Sun, 09 Jan 2022 13:16:16 GMT
Content-Type: text/html
Content-Length: 10
Last-Modified: Sun, 09 Jan 2022 09:55:02 GMT
Connection: keep-alive
Keep-Alive: timeout=60
ETag: "61dab0f6-a"
Accept-Ranges: bytes

index1 v3

 



这篇关于Nginx-隐藏版本号的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程