NGINX 优化与防盗链
1版本信息
如何查看版本信息
[root@localhost ~]#curl 192.168.91.103
[root@localhost ~]#curl -I 192.168.91.103
隐藏版本号
1.1修改配置文件
[root@localhost ~]#vim /usr/local/nginx/conf/nginx.conf
#加入 server_tokens off;
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
........
}
[root@localhost ~]#curl -I 192.168.91.103
1.2重新编译安装
[root@localhost nginx-1.12.0]#vim /opt/nginx-1.12.0/src/core/nginx.h
#define nginx_version 1012000
#define NGINX_VERSION "666"
#define NGINX_VER "IIS/" NGINX_VERSION
[root@localhost nginx-1.12.0]#cd /opt/nginx-1.12.0/
[root@localhost nginx-1.12.0]#
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
[root@localhost nginx-1.12.0]#make && make install
[root@localhost conf]# cd /usr/local/nginx/conf/
[root@localhost conf]# vim nginx.conf
####省略####
http {
include mime.types;
default_type application/octet-stream;
server_tokens on; ####打开版本号
[root@localhost conf]# systemctl restart nginx
[root@localhost conf]# curl -I http://192.168.91.100
HTTP/1.1 200 OK
Server: IIS1.1.1 ###显示信息设置
Date: Mon, 04 Mar 2019 17:38:18 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 244
Last-Modified: Mon, 04 Mar 2019 11:02:43 GMT
Connection: keep-alive
ETag: "5c7d05d3-f4"
Accept-Ranges: bytes
2修改用户与组
2.1在编译安装时设置
[root@localhost opt]# cd nginx-1.15.9/
[root@localhost nginx-1.15.9]#
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
2.2修改配置文件
2、配置用户与组
修改Nginx配置文件的Nginx指定用户与组
[root@loca