nginx之隐藏版本号
配置nginx
<代码> [root@localhost ~] # yum安装pcre-devel zlib-devel gcc gcc-c + + - y # #安装环境包 (root@localhost ~) # useradd - m - s/sbin/nologin nginx # #创建程序性用户 陈(root@localhost ~) # mkdir/# #创建挂载点 root@localhost ~ #山。cifs//陈192.168.100.23/LNMP/# #挂载 密码root@//192.168.100.23/LNMP: (陈root@localhost) #焦油zxvf nginx-1.12.2.tar。广州- c/opt/# #解压 (陈root@localhost) # cd/opt/root@localhost选择# ls nginx-1.12.2猕 root@localhost选择# cd nginx-1.12.2/[root@localhost nginx-1.12.2] # ls 汽车CHANGES.ru配置html src的男人 改变conf contrib许可证README ./configure \ # #安装nginx组件 ——prefix=/usr/地方/nginx \ ——用户=nginx \ ——组=nginx \ ——with-http_stub_status_module [root@localhost nginx-1.12.2] #做,,使安装# #编译 [root@localhost nginx-1.12.2] # ln - s/usr/local/nginx/sbin/nginx/usr/local/sbin/# #做软链接让系统能识别nginx的所有人命令 [root@localhost nginx-1.12.2] # nginx - t # #检查语法错误/usr/local/nginx/conf/nginx. nginx:配置文件配置语法好/usr/local/nginx/conf/nginx. nginx:配置文件配置测试是成功的代码>
写nginx脚本放在系统启动脚本中方便服务管理器管理
<代码> [root@localhost nginx-1.12.2] # cd/etc/init.d/# #到系统启动脚本 [root@localhost init。d] # vim nginx # #写一个nginx脚本 # !/bin/bash # chkconfig: - 99 20 #注释信息 描述:Nginx服务控制脚本 学监="/usr/地方/nginx/sbin/nginx”#这个变量,指向我的命令文件 PIDF="/usr/地方/nginx/logs/nginx。pid“#这个变量,指向nginx的进程号 “1美元” 开始) 美元掠夺 ;; 停止) 杀- s退出美元(猫PIDF美元) ;; 重启) 0美元停止 $ 0开始 ;; 重新加载) 杀- s玫瑰(猫PIDF美元美元) ;; *) 回声”用法:$ 0{启动|停止| |重启重载}” 出口1 esac 退出0 [root@localhost init。d] # chmod + x nginx # #给nginx提升权限 [root@localhost init。d] # chkconfig——添加nginx # #添加nginx [root@localhost init。d] #服务nginx的开始 [root@localhost init。d] # netstat -ntap | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0: * 17544/nginx听:主人 [root@localhost init。d] # systemctl firewalld.service停止 [root@localhost init。d] # setenforce 0 代码>
检查现在我们nginx的版本号
<代码> root@localhost ~ #卷发——http://192.168.136.163/HTTP/1.1 200 OK 服务器:nginx/1.12.2 时间:星期二,2019年11月05 07:30:14格林尼治时间 内容类型:text/html 内容长度:612 最后修改:星期二,2019年11月05 07:13:26格林尼治时间 连接:维生 ETag:“5 dc12116 - 264” Accept-Ranges:字节代码>
关闭版本号再检查一下
<代码> root@localhost ~ # vim/usr/local/nginx/conf/nginx.conf http{# #在http级别下添加 包括mime.types; default_type应用程序/八进制; server_tokens;# #关闭版本号 [root@localhost init。d] #服务nginx停止# #关闭服务 [root@localhost init。d] #服务nginx开始# #开启服务 [root@localhost init。d] # curl - http://192.168.136.163/# #查看Nginx信息 HTTP/1.1 200 OK 服务器:nginx # #版本号被隐藏了 时间:星期二,2019年11月12日14:22:00格林尼治时间 内容类型:text/html 内容长度:612 最后修改:星期二,2019年11月12日13:46:35格林尼治时间 连接:维生 ETag:“5 dcab7bb - 264” Accept-Ranges:字节代码>
伪造版本号
<代码> [root@localhost init。d] # vim/usr/local/nginx/conf/nginx.conf http { 包括mime.types; default_type应用程序/八进制; server_tokens/比;# #在第15行添加图片 代码> >之前设置缓存时间
<代码> [root@localhost html] # vim/usr/local/nginx/conf/nginx.conf # #在服务器服务器级别 76位置~ \ (gif | jepg | | icp jpg图片| bmp | png) ${# #加入能使别这些图片格式 77根html;# #管理员页面 78年到期的1 d;# #缓存时间1天 16个用户nginx nginx;# # 16行加入nginx用户和组 [html] root@localhost #服务nginx开始Nginx之隐藏版本号,优化缓存,日志分割