Linux Apache 第一次响应速度奇慢解决办法(2)

代码:
ExtendedStatus On
# Only needed if the module is compiled as a DSO
LoadModule limitipconn_module lib/apache/mod_limitipconn.so
<IfModule mod_limitipconn.c>
<Location /somewhere>
MaxConnPerIP 3
# exempting images from the connection limit is often a good
# idea if your web page has lots of inline images, since these
# pages often generate a flurry of concurrent image requests
# NoIPLimit image/*
# In this case, all MIME types other than audio/mpeg and video*
# are exempt from the limit check
# OnlyIPLimit audio/mpeg video
</Location>
</IfModule> 

注意: LoadModule limitipconn_module modules/mod_limitipconn.so 必须放在虚拟服务器之前!否则不能启动。

效果如下:我用flashget开了10线程,你可以看到只有两个线程起作用。

防盗链设置:

1. 在httpd.conf中加载mod_rewrite模块:

去掉#LoadModule rewrite_module modules/mod_rewrite.so 中的#号
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>,将AllowOverride None改成AllowOverride All
2. 在目录下新建一个.htaccess文件

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^*$ [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteCond %{HTTP_REFERER} !^*$ [NC]
RewriteCond %{HTTP_REFERER} !^$ [NC]
RewriteRule .*\.(gif|jpg|sis|rar|zip|iso|pdf|jpeg)$ [R,NC]
RewriteLog "logs/linuxidc.com_rewrite.log"
RewriteLogLevel 3

参数说明:

RewriteCond :rewrite规则定义,只有满足这里定义的规则,才执行rewrite
%{HTTP_REFERER} :表示链接的来源参照
!^(www\.)?linuxidc\.com/.*$ :表示与%{HTTP_REFERER}进行匹配的字符串
[NC] :nocase,表示在进行匹配的时候忽略大小写。当有多个RewriteCond时默认其关系为And,如果要改成OR,可用[NC, OR]表示
RewriteRule :当满足RewriteCond条件时,访问gif|jpg|sis|rar|zip|iso|pdf|jpeg文件就会被重定向到
RewriteLog : 日志文件,帮助分析rewrite规则是否正确

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wydyjf.html