一、NGINX 基本安全优化
1、隐藏NGINX软件版本号信息
[root@localhost nginx2]# curl -I 10.3.151.34
HTTP/1.1 502 Bad Gateway
Server: nginx/1.13.4
Date: Tue, 24 Jul 2018 01:22:28 GMT
Content-Type: text/html
Content-Length: 537
Connection: keep-alive
ETag: "5b505df9-219"
2、NGINX配置文件nginx.conf中的http标签段内加入“server_tokens off” 参数:
http
{
server_tokens off;
}
二、根据服务器性能调整worker进程个数
1、worker进程理解
NGINX服务有Master进程和worker进程之分,Maste为管理进程,Worker为工作进程,而Worker进程默认为1个,而在搭建服务器时,可根据CPU的核数进程设置。
2、查看服务器CPU核数
[root@localhost nginx2]# grep processor /proc/cpuinfo | wc -l
8
或者通过top命令,然后按“1”就可查看CPU核数
3、修改worker进程数
worker_processes 8;