技术 · 思考 · 实践 · 成长

首页/Nginx/正文

Nginx 性能优化

Nginx583 次阅读

一、Nginx基本安全优化

1、隐藏Nginx版本号


修改之前:

[root@node-a conf]# curl -I 47.93.209.191
HTTP/1.1 200 OK
Server: nginx/1.17.4
Date: Thu, 10 Nov 2022 09:01:05 GMT
Content-Type: text/html
Content-Length: 18
Last-Modified: Tue, 11 Oct 2022 08:46:38 GMT
Connection: keep-alive
ETag: "63452d6e-12"
Accept-Ranges: bytes


修改之后:

[root@node-a sbin]# curl -I 47.93.209.191
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 10 Nov 2022 09:05:07 GMT
Content-Type: text/html
Content-Length: 18
Last-Modified: Tue, 11 Oct 2022 08:46:38 GMT
Connection: keep-alive
ETag: "63452d6e-12"
Accept-Ranges: bytes


2、修改源码隐藏Nginx软件名称及版本号

3、更改Nginx服务的默认用户

4、优化Nginx服务的worker进程个数

5、关闭不需要的服务

6、优化写磁盘操作

7、优化资源限制

[root@node-a nginx-1.23.3]# ulimit -u
6943
[root@node-a nginx-1.23.3]# ulimit -n
65535
[root@node-a nginx-1.23.3]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 6943
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 6943
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


修改文件:

[root@node-a nginx-1.23.3]# vi /etc/security/limits.conf 
* soft nofile 65535
* hard nofile 65535

重新启动系统才会生效

8、优化内核TCP选项1


生活的强者,不是指能搞定一切困难,也不是指没有恐惧,而是就算心里藏着无尽的疲惫和委屈,还是会认真地做好手头上的事情;就算自己被生活锤得心灰意冷,还是会尽心尽力地负起责任;就算发现现实与理想的差距有十万里,虽然鞭长莫及,却依然马不停蹄。

评论交流

0 条评论 · 支持多级回复
验证码
暂无评论,来说说你的想法吧

相关文章

继续阅读