1.1)隐藏nginx header 内版本号信息

  1. [root@aliyun ~]# vi /application/nginx/conf/nginx.conf
  2. http{
  3.  
  4. ……
  5. server_tokens off;
  6. ……
  7.  
  8. }
  1. [root@aliyun ~]# curl -I 172.19.125.*
  2. HTTP/1.1 200 OK
  3. Server: nginx 没有版本号了
  4. Date: Mon, 11 Sep 2017 07:07:05 GMT
  5. Content-Type: text/html;charset=utf-8
  6. Connection: keep-alive
  7. X-Powered-By: PHP/5.3.27
  8. Set-Cookie: pcok=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; httponly

1.2)Apache去版本号的参数

  1. [root@server extra]# cat httpd-default.conf
  2. ServerTokens Prod
  3. ServerSignature off

2.1)更改nginx的默认用户及用户组nobody

  1. [root@aliyun conf]# grep 'user' nginx.conf.default
  2. #user nobody;
  3.  
  4. nginx一般都是在编译的时候指定的 --user=nginx --group=nginx

2.2)apache一般都是在配置文件里面指定

  1. [root@server conf]# egrep 'User|Group' httpd.conf
  2. # User/Group: The name (or #number) of the user/group to run httpd as.
  3. User www
  4. Group www

3.1)配置nginx worker进程个数 

在高并发场景,需要事先启动更多的nginx进程以保证快速响应并处理用户的请求
worker_processes 8;
建议指定和cpu的数量相等或乘2的进程数。
[root@aliyun ~]# grep 'physical id' /proc/cpuinfo

4.1)根据cpu核数进行nginx进程优化

默认情况下nginx的多个进程可能更多的跑在一颗cpu上,本节是分配不同的进程给不同的cpu处理,达到充分利用硬件多核多cpu的目的。

  1. 四核cpu服务器:
  2. worker_cpu_affinity 0001 0010 0100 1000;
  3. nginx进程cpu亲和力,即把不同的进程分给不同的cpu处理。这里0001 0010 0100 1000是掩码,分别代表1234cpu核心
  4.  
  5. 八核cpu服务器:
  6. worker_cpu_affinity 0001 0010 0100 1000 0001 0010 0100 1000

压力测试软件    ab ,webbench,,loadruner

5.1)事件处理模型优化

nginx的连接处理机制在于不同的操作系统采用不同的io模型,在linxu使用epoll的io多路复用模型,在freebsd使用kqueue的io多路复用模型,在solaris使用/dev/poll方式的io多路复用模型,在windows使用的是icop等等。
events{
use epoll;
}
use是个事件模块指令,用来指定nginx的工作模式。nginx支持的工作模式有select、poll、kqueue、epoll、rtsig和/dev/poll.其中select和poll都是标准的工作模式,kqueue和epoll是最高效的工作模式,不同的是epoll用在linux平台上,而kqueue用在bsd系统中。对于Linux系统linux2.6+的内核,推荐选择epoll工作模式,这是高性能高并发的设置。

6.1)调整单个进程允许的客户端最大连接数

这个值根据服务器性能和程序的内存使用量来指定(一个进程启动使用的内存根据程序确定)

  1. events{
  2. worker_connections 20480; 每个进程的最大连接数,默认1024
  3. }

7.1)配置每个进程最大文件打开数
worker_rlimit_nofile 65535;
每个进程打开的最大文件数,可设置为系统优化后的ulimit -HSn的结果,这个可以小一点不必这么大32768就可以。

8.1)优化服务器名字的hash表大小

确切名字和通配符名字存储在哈希表中。
例子:

  1. server{
  2. listen 80;
  3. server_name nginx.org www.nginx.org *.nginx.org;
  4. }

如果定义了大量名字,或者定义了非常长的名字,那就需要在http配置块中调整server_names_hash_max_size和server_names_hash_bucket_size的值。
server_names_hash_bucket_size的默认值可能是32,或者是64,或者是其他值,取决于cpu的缓存行的长度。如果这个值是32,那么定义“too.long.server.name.nginx.org”作为虚拟主机名就会失败,显示下面错误信息:could not build the server_names_hash,you should increase server_names_hash_bucket_size:32出现了这种情况,那就需要将设置值扩大一倍:

  1. http{
  2. server_names_hash_bucket_size 64;
  3. }

如果还不能解决问题,或者服务器启动非常缓慢,再尝试提高server_names_hash_bucket_size的值。如果server_name是一个含有捕获组的正则表达式,这是nginx就不得不执行这个表达式以得到捕获组。server_names_hash_max_size 512; #默认是512kb,一般要查看系统给出确切的值,这里一般cpu L1的4-5倍。

9.1)开启高效文件传输模式

sendfile on;
同时将tcp_nopush和tcp_nodelay两个指令设置为on用于防止网络阻塞。

10.1)设置连接超时时间

php  希望短连接  java长连接

  1. keepalive_timeout 60;
  2. 客户端连接保持会话的超时时间,超过这个时间,服务器会关闭该连接。
  3. tcp_nodelay on;
  4. 包含了keepalive参数才有效
  5. client_header_timeout 15;
  6. 设置客户端请求头读取超时时间,如超过这个时间,客户端还没有发送任何数据,nginx将返回“Request time out(408)”错误。
  7. client_body_timeout 15;
  8. 设置客户端请求主体读取超时时间,如超过这个时间,客户端还没有发送任何数据,nginx将返回“request time out(408)”错误,默认值是60.
  9. send_timeout 15;
  10. 响应客户端的超时时间。这个超时仅限于两个连接活动之间的时间,如果超过这个时间,客户端没有任何活动,nginx将会关闭连接

11.1)上传文件大小限制(动态应用)

主配置文件里加入如下参数
client_max_body_size 10m;
官方文档:
set the maximum allowed size of the client request body

12.1)fastcgi调优(配合php引擎动态服务)

  1. fastcgi_connect_timeout 300;
  2. 连接到后端fastcgi的超时时间
  3. fastcgi_send_timeout 300;
  4. fastcgi传送请求的超时时间,这个值是指已经完成两次握手后向fastcgi传送请求的超时时间。
  5. fastcgi_read_timeout 300;
  6. 接收fastcgi应答的超时时间,这个值是指已经完成两次握手后接收fastcgi应答的超时时间。
  7. fastcgi_buffer_size 64k;
  8. 读取fastcgi应答第一部分需要用多大的缓冲区,这个值表示将使用164KB的缓冲区读取应答的第一部分(应答头),
  9. 可以设置为fastcgi_buffers选项指定的缓冲区大小。
  10. fastcgi_buffers 4 64k;
  11. 本地需要用多少盒多大的缓冲区来缓冲fastcgi的应答请求。如果一个php脚本所产生的页面大小为256KB,那么会为其分配464KB的缓冲区来缓冲;如果页面大小大于256KB,那么大于256KB的部分会缓存到fastcgi_temp指定的路径中,但是这并不是好方法,因为内存中的数据处理速度要快鱼硬盘,一般这个值应该为站点中Php脚本所产生的页面大小的中间值,如果站点大部分脚本所产生的页面大小为256KB,那么可以把这个值设置为“16 、“4 64k”等。
  12. fastcgi_busy_buffers_size 128k;
  13. 建议为fastcgi_buffers的两倍
  14. fastcgi_temp_file_write_size 128k;
  15. 在写入fastcgi_temp_path时将用多大的数据块,默认值是fastcgi_buffers的两倍,设置上述数值设置太小时若负载上来时可能报502BAD GATEWAY
  16. fastcgi_cache oldboy_nginx;
  17. 开启fastcgi缓存并为其指定一个名称。开启缓存非常有用,可以有效降低cpu的负载,并且防止502错误的发生,但是开启缓存也可能会引起其他问题。
  18. fastcgi_cache_valid 200 302 1h;
  19. 用来指定应答代码的缓存时间,实例中的值表示将200302应答缓存一个小时
  20. fastcgi_cache_valid 301 1d;
  21. 301应答缓存1
  22. fastcgi_cache_valid any 1m;
  23. 将其他应答缓存为1分钟
  24. fastcgi_cache_min_uses 1;
  25. 缓存在fastcgi_cache_path指令inactive参数值时间内的最少使用次数

13.1)更改源码隐藏软件名称及版本号

  1. #修改/home/tools/nginx-1.6.2/src/core
  2.  
  3. 隐藏软件名称等操作
  4. /home/tools/nginx-1.6.2/src/http
  5. [root@aliyun http]# vim ngx_http_header_filter_module.c
  6.  
  7. 48
  8. static char ngx_http_server_string[] = "Server: nginx" CRLF;
  9. static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
  10. 改为
  11. static char ngx_http_server_string[] = "Server: nidaye" CRLF;
  12. static char ngx_http_server_full_string[] = "Server: nidaye " CRLF;
  13.  
  14. 此时就需要重新编译,需要备份的东西要备份,,,这面这个操作只改变了header,对于页面错误的信息要该下面与上相同目录,,,,这个最好跟上面的一起做了,不要重复编译
  15. [root@aliyun http]# vim ngx_http_special_response.c
  16.  
  17. static u_char ngx_http_error_tail[] =
  18. "<hr><center>nidaye</center>" CRLF
  19. "</body>" CRLF
  20. "</html>" CRLF
  21. ;

14.1)配置nginx gzip压缩模块

提供了对文件内容压缩的功能,允许nginx服务器将输出内容在发送到客户端之前根据具体的策略进行压缩,以节约网站带宽,同时提升用户访问体验,此功能同apache的mod_deflate压缩功能,依赖ngx_http_gzip_module模块,默认已安装。

需要压缩的所有程序(js,css,html,文本),不要压缩的内容(图片,视频,flash)

  1. gzip on;
  2. 开启gzip压缩功能
  3. gzip_min_length 1k;
  4. 允许压缩的页面最小字节数,页面字节数从header头的content-length中获取,默认值是0,不管哪个页面多大都进行压缩,建议设置成大于1k,如果小于1k可能会越压越大。
  5. gzip_buffers 4 32k;
  6. 申请4个单位为16k的内存作为压缩结果流缓存,默认值是申请与原始数据大小相同的内存空间来存储gzip压缩结果。
  7. gzip_http_version 1.1;
  8. 压缩版本(默认1.1,前端为squid2.5时使用1.0)用于设置识别HTTP协议版本,默认是1.1,目前大部分浏览器已经支持gzip解压,使用默认即可。
  9. gzip_comp_level 9;
  10. 压缩比率。用来指定gzip压缩比,1压缩比最小,处理速度最快;9压缩比最大,传输速度快,但处理最慢,比较消耗cpu资源
  11. gzip_types text/plain application/javascript text/css application/xml; 可以在nginx下的[root@aliyun conf]# cat mime.types查看类型,不同的版本可能不同,火狐有个插件yslow可以查看压缩情况,可能需要翻墙下载用来指定压缩的类型,“text/html”类型总是会被压缩。。
  12. gzip_vary on;
  13. 可以让前端的缓存服务器缓存经过gzip压缩的页面,缓存服务器里保存压缩过的缓存。

apache压缩模块

  1. DSO动态模块加载mod_deflate配置的全部命令为: cd /home/oldboy/tools/httpd-2.2.27/modules/filters/
  2. <==切到apache软件目录mod_deflate程序下。
  3. /application/apache/bin/apxs -c -i -a mod_deflate.c
  4. <==以dso的方式编译入到apache中。
  5. ll /application/apache/modules/mod_deflate.so
  6. <==检查mod_deflate
  7.  
  8. 配置文件的修改
  9. <ifmodule mod_deflate.c>
  10. DeflateCompressionLevel 9
  11. SetOutputFilter DEFLATE
  12. AddOutputFilterByType DEFLATE text/html text/plain text/xml
  13. AddOutputFilterByType DEFLATE application/javascript
  14. AddOutputFilterByType DEFLATE text/css
  15. </ifmodule>

15.1)nginx expires缓存功能

为了缓解网站访问的访问压力,我们应该尽量将客户访问内容往前推,能够放到客户端的就不要放到CDN,能够放到CDN的就不用放到本地服务器,充分的利用每一层的缓存,直到万不得已才让客户访问到我们的数据存上去。

expires
好处:
  1、第一次以后,访问网站快
  2、节省服务带宽,,,成本
  3、服务器压力降低。成本
坏处:
  1、网站改版,对应的用户看到的还是旧的(js,css,图片)

解决坏处:
  1、过期的时间短一些。
  2、资源文件更新时,改名。

配置ngxin expires,,,,这个需要放在server标签下

  1. 1、根据文件扩展名进行判断
  2. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  3. {
  4. expires 3650d;
  5. root html/bbs;
  6. }
  7. location ~ .*\.(js|css)?$
  8. {
  9. expires 30d;
  10. root html/bbs;
  11. }
  12.  
  13. 2、根据目录进行判断
  14. ## Add expires header according to dir.
  15. location ~ ^/(images|javascript|js|css|flash|media|static)/ {
  16. expires 360d;
  17. }
  18.  
  19. 3、单个文件判断
  20. robots.txt设置过期时间,这里为robots7天并不记录404错误日志
  21. location ~(robots.txt){
  22. log_not_found off;
  23. expires 7d;
  24. break;
  25.  
  26. }

apache的这个过期时间跟上面的压缩源码添加差不多,但是为了省去麻烦还是在编译的时候就设置好

  1. ExpiresActive on
  2. ExpiresDefault "access plus 12 month"
  3. ExpiresByType text/html "access plus 12 months"
  4. ExpiresByType text/css "access plus 12 months"
  5. ExpiresByType image/gif "access plus 12 months"
  6. ExpiresByType image/jpeg "access plus 12 months"
  7. ExpiresByType image/jpg "access plus 12 months"
  8. ExpiresByType image/png "access plus 12 months"
  9. EXpiresByType application/x-shockwave-flash "access plus 12 months"
  10. EXpiresByType application/x-javascript "access plus 12 months"
  11. ExpiresByType video/x-flv "access plus 12 months"

16.10)nginx防爬虫案例

参考:http://blog.csdn.net/xifeijian/article/details/38615695

防止客户端是火狐或者IE的访问,,,,,,不同的爬虫所对应的agent也是不一样的

  1. if ($http_user_agent ~* "Firefox|MSIE")
  2. {
  3. return 403;
  4. }
  5.  
  6. 下面是在真个篇幅下,这个的所处位置环境
  7. server {
  8. listen 80;
  9. server_name bbs.etiantian.org;
  10. root html/bbs;
  11. index index.php index.html index.htm;
  12. if ($http_user_agent ~* "Firefox|MSIE")
  13. {
  14. return 403;
  15. }
  16. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  17. {
  18. expires 3650d;
  19. root html/bbs;
  20. }
  21. location ~ .*\.(js|css)?$
  22. {
  23. expires 30d;
  24. root html/bbs;
  25. }
  26. location ~.*\.(php|php5)?$ {
  27. root html/bbs;
  28. fastcgi_pass 127.0.0.1:9000;
  29. fastcgi_index index.php;
  30. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  31. include fastcgi.conf;
  32. }
  33. }

~ 区分大小写(大小写敏感)匹配成功
~* 不区分大小写匹配成功
!~ 区分大小写匹配失败
!~* 不区分大小写匹配失败

17.1)nginx日志轮询

  1. mkdir /server/scripts/ -p
  2. cd /server/scripts/
  3. vim cut_nginx_log.sh
  4. cd /application/nginx/logs && \
  5. /bin/mv www_access.log www_access_$(date +%F -d -1day).log
  6. /application/nginx/sbin/nginx -s reload

然后将这段脚本加入crontab

18.1)NGINX不记录不需要的访问日志,对于健康检查或某些图片不需要记录,而且日志写入频繁会消耗磁盘IO,降低服务性能。

  1. location ~ .*\.(js|jpg|JPG|jpeg|JPEG|css|bmp|gif|GIF)$
  2. {
  3. access_log off;
  4. }

apache呢

  1. 配置方法:
  2. <FilesMatch "\.(css|js|gif|jpg|ico|swf)">
  3. SetEnv IMAG 1
  4. </FilesMatch>
  5. 日志配置:
  6. CustomLog "|/usr/local/sbin/cronolog /app/logs/%Y/%m/access_%Y%m%d.log" combined env=!IMAG
  7. CustomLog "|/usr/local/sbin/cronolog /app/logs/%Y/%m/%d/access_%Y%m%d%H.log" combined env=!IMAG

19.1)最小化目录及文件权限设置

安全的权限:
所有站点目录的用户和组都应该为root
所有目录权限是默认的755
所有文件权限是默认的644
注意,网站服务的用户不能用root。
以上的权限的设置可以做到防止黑客上传木马,以及修改站点文件,但是合理的用户上传的内容也被拒之门外了。====
要解决上面的问题,,,就要对业务进行分离,在比较好的网站架构中,应把资源文件,包括用户上传的图片,附件等的服务和程序服务分离,最好把上传程序服务也分离,这样就可以从容按照前面安全的标准授权了。

20.1)nginx站点目录及文件URL访问控制

根据扩展名限制程序和文件访问

1)nginx下禁止访问资源目录下的PHP程序被解析,禁止images目录下的php文件被访问

  1. location ~ ^/images/.*\.(php|php5)$ {
  2. deny all;
  3. }
  4.  
  5. location ~ ^/static/.*\.(php|php5)$ {
  6. deny all;
  7. }
  8.  
  9. location ~* ^/data/(attachment|avatar)/.*\.(php|php5)$ {
  10. deny all;
  11. }
  12.  
  13. 但是上面这些需要放在下面的前面
  14. location ~.*\.(php|php5)?$ {
  15. root html/bbs;
  16. fastcgi_pass 127.0.0.1:9000;
  17. fastcgi_index index.php;
  18. include fastcgi.conf;
  19. }

2)Nginx下配置禁止访问*.txt文件

  1. location ~* \.(txt|doc)$ {
  2. if (-f $request_filename){
  3. root /data/www/www;
  4. #rewrite …..可以重定向到某个URL
  5. break;
  6. }
  7. }
  8.  
  9. location ~* \.(txt|doc)${
  10. root /data/www/www;
  11. deny all;
  12. }
  1. 单目录:
  2. location ~ ^/(static)/ {
  3. deny all;
  4. }
  5. location ~ ^/static {
  6. deny all;
  7. }
  8. 多目录:
  9. location ~ ^/(static|js) {
  10. deny all;
  11. }
  12. location /admin/ {
  13. return 404;
  14. }
  15. location /templates/ {
  16. return 403;
  17. }

禁止某目录让外界访问,但允许某ip访问该目录,且支持PHP解析

  1. location ~ ^/oldboy/ {
  2. allow 202.111.12.211;
  3. deny all;
  4. }
  5.  
  6. location / {
  7. deny 192.168.1.1;
  8. allow 192.168.1.0/24;
  9. allow 10.1.1.0/16;
  10. deny all;
  11. }

状态码:http://oldboy.blog.51cto.com/2561410/716294
消息(1字头)
成功(2字头)
重定向(3字头)
请求错误(4字头)
服务器错误(5字头)

21.1)优雅的错误页面

  1. server标签下
  2. error_page 403 /403.html 此路径相对于root html/www
  3.  
  4. error_page 500 502 503 504 /50x.html;
  5. location = /50x.html{
  6. root html;
  7. }
  8. 位于html目录下

 

  1. 门户网站案例
  2. error_page 400 http://err.tmall.com/error1.html;
  3. error_page 403 http://err.tmall.com/error1.html;
  4. error_page 404 http://err.tmall.com/error1.html;
  5. error_page 405 http://err.tmall.com/error1.html;
  6. error_page 408 http://err.tmall.com/error1.html;
  7. error_page 410 http://err.tmall.com/error1.html;
  8. error_page 411 http://err.tmall.com/error1.html;
  9. error_page 412 http://err.tmall.com/error1.html;
  10. error_page 413 http://err.tmall.com/error1.html;
  11. error_page 415 http://err.tmall.com/error1.html;
  12. error_page 500 http://err.tmall.com/error2.html;
  13. error_page 501 http://err.tmall.com/error2.html;
  14. error_page 502 http://err.tmall.com/error2.html;
  15. error_page 503 http://err.tmall.com/error2.html;
  16. error_page 506 http://err.tmall.com/error2.html;
  17.  
  18. 淘宝的web服务器
  19. http://tengine.taobao.org/

22.1)使用tmpfs文件系统代替频繁访问的目录

  1. tmpfs,临时文件系统,是一种基于内存的文件系统。
  2.  
  3. 可以配置eaccelerator缓存目录
  4. mkdir -p /tmp/eaccelerator
  5. 此目录可以用tmpfs内存文件系统来存储,ssd固态硬盘
  6. chown -R nginx.nginx /tmp/eaccelerator
  7.  
  8. 也可以重新搞一个目录
  9. [root@aliyun ~]# mkdir -p /tmpfs
  10. [root@aliyun ~]# mount -t tmpfs -o size=16m tmpfs /tmpfs
  11. [root@aliyun ~]# df -h
  12. Filesystem Size Used Avail Use% Mounted on
  13. /dev/vda1 40G 5.4G 32G 15% /
  14. tmpfs 499M 0 499M 0% /dev/shm
  15. tmpfs 16M 0 16M 0% /tmpfs
  16.  
  17. -t 类型 第二个tmpfs是设备名 正常情况下可以设置空间为2G4G
  18. 然后可以放到/etc/fstab或者/etc/rc.loacl

23.1)apache不解析php

  1. 方法1:提示下载不解析
  2. <Directory ~ "/application/www/etiantian/bbs/attachments">
  3. Options FollowSymLinks
  4. AllowOverride None
  5. Order allow,deny
  6. Allow from all
  7. php_flag engine off #注意这行
  8. </Directory>
  9.  
  10. 方法2:这个会包含403
  11. <Directory /var/html/blog>
  12. <Files ~ ".php">
  13. Order allow,deny
  14. Deny from all
  15. </Files>
  16. </Directory>

24.1)Tcmalloc优化Nginx性能(自己判断要不要使用)
TCMalloc的全称为Thread-Caching Malloc,是谷歌开发的开源工具“google-perftools”中的一个成员。与标准的glibc库的malloc相比,TCMalloc库在内存分配效率和速度上要高很多,这在很大程度上提高了服务器在高并发情况下的性能,从而降低系统负载。下面简单介绍如何为Nginx添加TCMalloc库支持。

25.1)

  1. vim proxy.conf
  2.  
  3. proxy_redirect off;
  4. proxy_set_header Host $host;
  5. proxy_set_header X-Real-IP $remote_addr;
  6. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  7. client_max_body_size 50m;
  8. client_body_buffer_size 256k;
  9. proxy_connect_timeout 30;
  10. proxy_send_timeout 30;
  11. proxy_read_timeout 60;
  12.  
  13. proxy_buffer_size 4k;
  14. proxy_buffers 4 32k;
  15. proxy_busy_buffers_size 64k;
  16. proxy_temp_file_write_size 64k;
  17. proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
  18. proxy_max_temp_file_size 128m;
  19. proxy_store on;
  20. proxy_store_access user:rw group:rw all:r;
  21. #proxy_temp_path /dev/shm/nginx_proxy;
  22. #proxy_temp_path /data2/nginx_cache;
  23.  
  24. 然后再具体的站点的下面
  25. 例如
  26. location ~.*\.(php|php5)?$ {
  27. root html/bbs;
  28. fastcgi_pass 127.0.0.1:9000;
  29. fastcgi_index index.php;
  30. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  31. include fastcgi.conf;
  32. include proxy.conf;
  33. }
  34.  
  35. 配置文件在conf下,,,然后配置在extra下的虚拟主机里

25.1)Nginx多实例,,,,,指定不同的配置文件,不同的端口就可以实现多实例

  

企业级web nginx服务优化的更多相关文章

  1. 企业级Web Nginx 服务优化

    企业级Web Nginx 服务优化 http://blog.51cto.com/search/result?q=%E4%BC%81%E4%B8%9A%E7%BA%A7Web+Nginx+%E6%9C% ...

  2. nginx服务优化大全

    第18章 nginx服务优化 18.1 复习以前的nginx知识 18.1.1 复习nginx编译安装的3部曲 ./configure        配置(开启/关闭功能),指定安装目录 make   ...

  3. 【实战分享】又拍云 OpenResty / Nginx 服务优化实践

    2018 年 11 月 17 日,由 OpenResty 主办的 OpenResty Con 2018 在杭州举行.本次 OpenResty Con 的主题涉及 OpenResty 的新开源特性.业界 ...

  4. Nginx服务优化详解

    Nginx服务优化详解 1.隐藏Nginx版本信息 编辑主配置文件nginx.conf,在http标签中添加代码 server_tokens off;来隐藏软件版本号. 2.更改Nginx服务启动的默 ...

  5. Nginx服务优化及优化深入(配置网页缓存时间、日志切割、防盗链等等)

    原文:https://blog.51cto.com/11134648/2134389 默认的Nginx安装参数只能提供最基本的服务,还需要调整如网页缓存时间.连接超时.网页压缩等相应参数,才能发挥出服 ...

  6. Nginx服务优化

    1.1Nginx.conf配置文件基本参数优化 1.1.1  隐藏nginx header内版本号信息 一些特定的系统及服务漏洞一般都和特定的软件及版本号有关,我们应尽量隐藏服务器的敏感信息(软件名称 ...

  7. Nginx服务优化配置

    1.expires缓存模块 具体配置可参考官方文档 http://nginx.org/en/docs/http/ngx_http_headers_module.html#expires [root@c ...

  8. Linux实战教学笔记38:企业级Nginx Web服务优化实战(下)

    四,Nginx站点目录及文件URL访问控制 4.1 根据扩展名限制程序和文件访问 Web2.0时代,绝大多数网站都是以用户为中心多的,例如:bbs,blog,sns产品,这几个产品都有一个共同特点,就 ...

  9. Linux实战教学笔记37:企业级Nginx Web服务优化实战(上)

    一,Nginx基本安全优化 1.1 调整参数隐藏Nginx软件版本号信息 一般来说,软件的漏洞都和版本有关,这个很像汽车的缺陷,同一批次的要有问题就都有问题,别的批次可能就都是好的.因此,我们应尽量隐 ...

随机推荐

  1. CDH 安装配置指南(Tarball方式)

    采用CDH Tarbal方式安装Hadoop集群. 1. 环境组件版本 组件名称 组件版本 用途 jdk 1.8 jdk-8u191-linux-x64 oracle jdk mysql mysql- ...

  2. 为什么43%前端开发者想学Vue.js

    根据JavaScript 2017前端库状况调查 Vue.js是开发者最想学的前端库.我在这里说明一下我为什么认为这也是和你一起通过使用Vue构建一个简单的App应用程序的原因. 我最近曾与Evan ...

  3. 【BZOJ】2021: [Usaco2010 Jan]Cheese Towers(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=2021 噗,自己太弱想不到. 原来是2次背包. 由于只要有一个大于k的高度的,而且这个必须放在最顶,那 ...

  4. ProtocolBuffer在Android端的解析

    开题篇 近期公司在使用Protocol Buffer替代原先的json作为移动端的数据交互格式.虽然服务端和CTO把这项新技术吹的天花乱坠,说什么体积小,不易被破解乱七八糟的.可是作为Android端 ...

  5. kafka 安装步骤

    kafka安装文档 1.解压缩(官网下载:http://kafka.apache.org/downloads.html) tar -xzf kafka_2.10-0.8.2.0.tgz cd kafk ...

  6. ie tbody table 兼容方法

    IE6-IE9中tbody的innerHTML不能赋值,重现代码如下 Js代码 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 2 ...

  7. Manacher模板,kmp,扩展kmp,最小表示法模板

    *N]; //储存临时串 *N];//中间记录 int Manacher(char tmp[]) { int len=strlen(tmp); ; ;i<len;i++) { s[cnt++]= ...

  8. JAVA环境变量配置备忘

    jdk1.6以上就不需要配置classpath了:系统会自动帮你配置好 选择“高级”选项卡,点击“环境变量”:在“系统变量”中,设置3项属性,JAVA_HOME,PATH,CLASSPATH(大小写无 ...

  9. 火狐 a 标签 download 属性,要在 a 标签添加到页面中才生效;

    在 chrome 中,如果需要设置点击下载文件,需要创建一个 a 标签,指定 download 属性和 href 属性即可, var aLink = document.createElement('a ...

  10. Storm 架构图

    画的丑,勉强看看吧 Nimbus我感觉他就像人的大脑一样! 当客户端给这个人发送了段信息 ,这个人的大脑就接收到这段信息,这个人不简单,是幕后大佬,一般不自己去干活,都是交给下面二当家去执行,当时这个 ...