Nginx服务优化 ---- 隐藏版本号 、页面缓存

本文介绍了如何在Nginx服务中隐藏版本号以提高安全性,包括修改配置文件和源码文件两种方法,并详细阐述了页面缓存的配置过程,以提升网站访问速度。
摘要由CSDN通过智能技术生成

Nginx服务优化 ---- 隐藏版本号 、页面缓存

一:配置Nginx隐藏版本号

  • 在生产环境中,需要隐藏Nginx的版本号,以避免安全漏洞的泄漏
1、查看方法
  • 使用fiddler工具在Windows客户端查看Nginx版本号

  • 在CentOS系统中使用"curl -I 网址”命令查看

2、Nginx隐藏版本号的方法
  • 修改配置文件法

  • 修改源码法

二:实验过程

1、首先先安装好nginx服务
[root@localhost ~]# yum install gcc gcc-c++ zlib-devel pcre pcre-devel -y            ‘安装依赖包’
[root@localhost ~]# useradd -M -s /sbin/nologin nginx        ‘创建名为nginx的用户,不允许登录系统’
[root@localhost ~]# mkdir /abc
[root@localhost ~]# mount.cifs //192.168.10.29/share /abc       ‘挂载共享文件’
[root@localhost abc]# tar zxvf nginx-1.12.2.tar.gz -C /opt/           ‘解压nginx压缩包’
[root@localhost opt]# cd nginx-1.12.2/
[root@localhost nginx-1.12.2]# ./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module          '安装统计模块'

[root@localhost nginx-1.12.2]# make && make install
[root@localhost nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin      '优化路径'
[root@localhost nginx-1.12.2]# nginx -t      ‘检测是否有误’
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configurat
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值