网站首页 > 博客文章 正文
一般使用nginx的web网站,访问网站时,可以从请求头中看到使用了nginx以及nginx的版本号。暴露这些信息将给网站带来一定的风险,因此安装nginx时最好把这些信息隐藏。
隐藏nginx 版本号与WEB服务器信息
如果未安装nginx,先去官网下载压缩包并解压到指定目录,然后进入nginx安装目录
1、 修改src/http文件夹下的两个文件,具体见下图
(1)修改src/http/ngx_http_header_filter_module.c文件
vim src/http/ngx_http_header_filter_module.c
#大约在49行, 修改Server后面服务器信息为自定义服务器信息
static u_char ngx_http_server_string[] = "Server: listen/1.1" CRLF;
改成自定义名称:
(2)修改src/http/ngx_http_special_response.c文件
vim src/http/ngx_http_special_response.c
#大约在36行,修改为自定义服务器信息
"<hr><center>listen/1.1</center>" CRLF
改成自定义名称
2、编译配置(如果已经安装过nginx,这一步需要先通过nginx –V查看安装信息,然后把相关配置加入下面配置中)
./configure --prefix=/usr/local/src/nginx
3、编译安装(已经安装过的这步只执行make,不执行make install,不然会把以前的配置覆盖,编译后直接手动复制nginx执行文件到原安装目录)
make && make install
4、修改nginx配置文件,http节点下添加 server_tokens off
vim /usr/local/nginx/conf/nginx.conf
....
http {
server_tokens off;
.....
5、启动nginx(正在运行的,需要杀掉进程再重新启动)
/usr/local/src/nginx/sbin/nginx
6、测试
[root@node1 nginx]# sudo curl -I http://127.0.0.1
HTTP/1.1 200 OK
Server: listen/1.1
Date: Fri, 16 Oct 2020 10:49:48 GMT
Content-Type: text/html;charset=ISO-8859-1
Connection: keep-alive
Vary: Accept-Encoding
浏览器访问如下,看不出网站使用了nginx。
主要:如果只想隐藏版本号,而不想自定义服务器信息,则不需要修改src/http下的ngx_http_header_filter_module.c和ngx_http_special_response.c文件
猜你喜欢
- 2024-10-05 Nginx + FastCGI 程序(C/C++) 搭建高性能web service
- 2024-10-05 Docker使用Nginx制作静态文件服务器
- 2024-10-05 使用nginx将服务器升级为https(nginx代理服务器配置)
- 2024-10-05 vue项目打包后部署到nginx(vue打包 nginx)
- 2024-10-05 Nginx Windows详细安装部署教程(nginx安装及配置教程)
- 2024-10-05 Vue实战091:Vue项目部署到nginx服务器
- 2024-10-05 Zabbix4.0企业级搭建实战(1)LNMP之Nginx服务器编译安装
- 2024-10-05 Linux上安装Nginx服务器(linux安装nginx详细步骤)
- 2024-10-05 Nginx 整合 FastDFS 实现文件服务器
- 2024-10-05 Linux中如何简单快速安装nginx以及如何配置
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)