HonestQiao 回復于:2004-07-13 20:38:25 |
可以禁止百度的阿 |
jackieyuan 回復于:2004-07-13 21:05:35 |
[quote:eb8ddbe9ff="HonestQiao"]可以禁止百度的阿[/quote:eb8ddbe9ff]
但是百度沒有訪問我阿,是從他導向我而已。 |
wd 回復于:2004-07-13 21:11:39 |
敗毒肯定得先訪問你,才能知道你上面有什么資源吧,他如果訪問不到你,那就沒戲了吧 |
jackieyuan 回復于:2004-07-13 21:15:15 |
[quote:d07f15e62d="wd"]敗毒肯定得先訪問你,才能知道你上面有什么資源吧,他如果訪問不到你,那就沒戲了吧[/quote:d07f15e62d]噢~! 是這個意思阿~ 但是現在已經沒辦法了。他今天導向我的連接就有[b:d07f15e62d]189220[/b:d07f15e62d] ,而且還在不停地寫error (forbidden)的日志,現在怎么阻止呢? :em06: |
jhsea3do 回復于:2004-07-13 23:49:46 |
放個 robots.txt 先把
這樣可以把原先被收錄的葉面拿掉 |
skylove 回復于:2004-07-14 16:28:44 |
我的媽呀,還好先看到了,否則以后就慘了 。。。 |
jackieyuan 回復于:2004-07-14 16:59:54 |
同志們 有沒有什么辦法用盜鏈圖片 的原理禁止阿~~ 我似乎禁止不了阿~ 會出現 [color=red:ccb3959ab4][size=18:ccb3959ab4][b:ccb3959ab4]206[/b:ccb3959ab4][/size:ccb3959ab4][/color:ccb3959ab4] 的代碼~~
[code:1:ccb3959ab4]211.100.104.153 - - [14/Jul/2004:16:59:39 +0800] "GET /archives/images/jiangnan.mp3 HTTP/1.1" [size=18][color=red]206[/color] [/size][b]1981302[/b] "http://mydomain.com/archives/images" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)"[/code:1:ccb3959ab4] 206代碼啥意思阿~ 后面是不是傳輸的數據? 因為這個數字老是變。 [code:1:ccb3959ab4]SetEnvIfNoCase Referer "mydomain\.com" local_ref=1 SetEnvIfNoCase Referer SetEnvIfNoCase Referer "-" local_ref=1 SetEnvIf Request_URI "/favicon.ico" local_ref=0 <FilesMatch "\.(png|gif|jpg|mp3|wma)"> Order Allow,Deny Allow from env=local_ref </FilesMatch>[/code:1:ccb3959ab4] 參考 http://httpd.apache.org/docs-2.0/mod/mod_setenvif.html#setenvif http://apache-server.com/tutorials/ATimage-theft.html 現在我的log統計已經到了這種瘋狂的地步了~~ [quote:ccb3959ab4]HTTP 錯誤碼 HTTP 錯誤碼* 文件數 百分比 字節 403 Forbidden [color=red:ccb3959ab4]472165 [/color:ccb3959ab4]84.1 % 167.27 M字節 206 Partial Content 88455 15.7 % 238.68 G字節 404 Document Not Found 680 0.1 % 241.08 K字節 416 Requested range not valid 44 0 % 19.59 K字節 301 Moved permanently (redirect) 11 0 % 4.18 K字節 [/quote:ccb3959ab4] 紅色是連接數目~~ 才一天半~ 暈~ :em10: |
skylove 回復于:2004-07-14 18:07:37 |
不記錄error,直接丟到/dev/null行不。。。雖然。。。比較危險了點點 |
HonestQiao 回復于:2004-07-14 22:34:41 |
來自于白度的連接不記錄到日志里面,很簡單做到的哦 |
jackieyuan 回復于:2004-07-14 23:40:58 |
[quote:2178e2de4e="HonestQiao"]來自于白度的連接不記錄到日志里面,很簡單做到的哦[/quote:2178e2de4e]老大~別吊人家胃口~說說吧~~ :em02: |
HonestQiao 回復于:2004-07-15 09:28:56 |
http://w.yi.org/ftp/FAPM/apache/Apache2/zh/logs.html
有條件地記錄日志 許多時候,使用 環境變量 排除某些客戶請求會帶來便利。首先,需要用SetEnvIf指令來標識符合某種條件的請求,然后用CustomLog 指令的env=從句,來包含或者排除被記錄的請求。例如: # Mark requests from the loop-back interface SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog # Mark requests for the robots.txt file SetEnvIf Request_URI "^/robots\.txt$" dontlog # Log what remains CustomLog logs/access_log common env=!dontlog 再例,記錄使用英語的請求到一個日志,而記錄非英語的請求到另一個日志: SetEnvIf Accept-Language "en" english CustomLog logs/english_log common env=english CustomLog logs/non_english_log common env=!english 雖然上述已經展示了有條件日志記錄的強大和靈活,但這不是控制日志內容的唯一手段,還可以用日志后處理程序來剔除你不關心的內容,而使日志更有用。 |
HonestQiao 回復于:2004-07-15 09:29:56 |
Apache模塊 mod_setenvif
說明: Allows the setting of environment variables based on characteristics of the request 狀態: Base 模塊名: setenvif_module 源文件: mod_setenvif.c 概要 The mod_setenvif module allows you to set environment variables according to whether different aspects of the request match regular expressions you specify. These environment variables can be used by other parts of the server to make decisions about actions to be taken. The directives are considered in the order they appear in the configuration files. So more complex sequences can be used, such as this example, which sets netscape if the browser is mozilla but not MSIE. BrowserMatch ^Mozilla netscape BrowserMatch MSIE !netscape 指令索引 BrowserMatch BrowserMatchNoCase SetEnvIf SetEnvIfNoCase 參見 Environment Variables in Apache BrowserMatch 指令 說明: Sets environment variables conditional on HTTP User-Agent 語法: BrowserMatch regex [!]env-variable[=value] [[!]env-variable[=value]] ... 上下文: 服務器配置, 虛擬主機, 目錄, .htaccess 覆蓋項: FileInfo 狀態: Base 模塊: mod_setenvif The BrowserMatch is a special cases of the SetEnvIf directive that sets environment variables conditional on the User-Agent HTTP request header. The following two lines have the same effect: BrowserMatchNoCase Robot is_a_robot SetEnvIfNoCase User-Agent Robot is_a_robot Some additional examples: BrowserMatch ^Mozilla forms jpeg=yes browser=netscape BrowserMatch "^Mozilla/[2-3]" tables agif frames javascript BrowserMatch MSIE !javascript BrowserMatchNoCase 指令 說明: Sets environment variables conditional on User-Agent without respect to case 語法: BrowserMatchNoCase regex [!]env-variable[=value] [[!]env-variable[=value]] ... 上下文: 服務器配置, 虛擬主機, 目錄, .htaccess 覆蓋項: FileInfo 狀態: Base 模塊: mod_setenvif 兼容性: Apache 1.2 and above (in Apache 1.2 this directive was found in the now-obsolete mod_browser module) The BrowserMatchNoCase directive is semantically identical to the BrowserMatch directive. However, it provides for case-insensitive matching. For example: BrowserMatchNoCase mac platform=macintosh BrowserMatchNoCase win platform=windows The BrowserMatch and BrowserMatchNoCase directives are special cases of the SetEnvIf and SetEnvIfNoCase directives. The following two lines have the same effect: BrowserMatchNoCase Robot is_a_robot SetEnvIfNoCase User-Agent Robot is_a_robot SetEnvIf 指令 說明: Sets environment variables based on attributes of the request 語法: SetEnvIf attribute regex [!]env-variable[=value] [[!]env-variable[=value]] ... 上下文: 服務器配置, 虛擬主機, 目錄, .htaccess 覆蓋項: FileInfo 狀態: Base 模塊: mod_setenvif The SetEnvIf directive defines environment variables based on attributes of the request. The attribute specified in the first argument can be one of three things: An HTTP request header field (see RFC2616 for more information about these); for example: Host, User-Agent, Referer, and Accept-Language. A regular expression may be used to specify a set of request headers. One of the following aspects of the request: Remote_Host - the hostname (if available) of the client making the request Remote_Addr - the IP address of the client making the request Server_Addr - the IP address of the server on which the request was received (only with versions later than 2.0.43) Remote_User - the authenticated username (if available) Request_Method - the name of the method being used (GET, POST, et cetera) Request_Protocol - the name and version of the protocol with which the request was made (e.g., "HTTP/0.9", "HTTP/1.1", etc.) Request_URI - the resource requested on the HTTP request line -- generally the portion of the URL following the scheme and host portion without the query string The name of an environment variable in the list of those associated with the request. This allows SetEnvIf directives to test against the result of prior matches. Only those environment variables defined by earlier SetEnvIf[NoCase] directives are available for testing in this manner. 'Earlier' means that they were defined at a broader scope (such as server-wide) or previously in the current directive's scope. Environment variables will be considered only if there was no match among request characteristics and a regular expression was not used for the attribute. The second argument (regex) is a Perl compatible regular expression. This is similar to a POSIX.2 egrep-style regular expression. If the regex matches against the attribute, then the remainder of the arguments are evaluated. The rest of the arguments give the names of variables to set, and optionally values to which they should be set. These take the form of varname, or !varname, or varname=value In the first form, the value will be set to "1". The second will remove the given variable if already defined, and the third will set the variable to the literal value given by value. Example: SetEnvIf Request_URI "\.gif$" object_is_image=gif SetEnvIf Request_URI "\.jpg$" object_is_image=jpg SetEnvIf Request_URI "\.xbm$" object_is_image=xbm : SetEnvIf Referer www\.mydomain\.com intra_site_referral : SetEnvIf object_is_image xbm XBIT_PROCESSING=1 : SetEnvIf ^TS* ^[a-z].* HAVE_TS The first three will set the environment variable object_is_image if the request was for an image file, and the fourth sets intra_site_referral if the referring page was somewhere on the www.mydomain.com Web site. The last example will set environment variable HAVE_TS if the request contains any headers that begin with "TS" whose values begins with any character in the set [a-z]. 參見 Environment Variables in Apache, for additional examples. SetEnvIfNoCase 指令 說明: Sets environment variables based on attributes of the request without respect to case 語法: SetEnvIfNoCase attribute regex [!]env-variable[=value] [[!]env-variable[=value]] ... 上下文: 服務器配置, 虛擬主機, 目錄, .htaccess 覆蓋項: FileInfo 狀態: Base 模塊: mod_setenvif 兼容性: Apache 1.3 and above The SetEnvIfNoCase is semantically identical to the SetEnvIf directive, and differs only in that the regular expression matching is performed in a case-insensitive manner. For example: SetEnvIfNoCase Host Apache\.Org site=apache This will cause the site environment variable to be set to "apache" if the HTTP request header field Host: was included and contained Apache.Org, apache.org, or any other combination |
jackieyuan 回復于:2004-07-15 09:58:36 |
[quote:91367a1772="HonestQiao"] ...
上下文: 服務器配置, 虛擬主機, 目錄, .htaccess 覆蓋項: FileInfo 狀態: Base 模塊: mod_setenvif 兼容性: Apache 1.3 and above The SetEnvIfNoCase is semantically identical to the SetEnvI..........[/quote:91367a1772] 現學現賣~~~ [code:1:91367a1772]######## Preventing Image 'Theft' ######## ## http://apache-server.com/tutorials/ATimage-theft.html # Images can only be fetched if they were linked to from one of your pages. # local_ref=1 or !local_ref ==> forbidden SetEnvIfNoCase Referer "fjhr\.org" local_ref=1 SetEnvIfNoCase Referer "hzmjp\.com" local_ref=1 SetEnvIfNoCase Referer "dalouis\.com" local_ref=1 SetEnvIfNoCase Referer "necktie\.gov\.cn" local_ref=1 SetEnvIfNoCase Referer "necktie\.net\.cn" local_ref=1 SetEnvIfNoCase Referer "hzboxing\.com" local_ref=1 SetEnvIfNoCase Referer "-" local_ref=1 SetEnvIf Request_URI "/images/logo(.)+" local_ref=0 SetEnvIf Request_URI "/images/snap(.)+" local_ref=0 SetEnvIf Request_URI "/images/close(.)+" local_ref=0 SetEnvIf Request_URI "/favicon\.ico" local_ref=0 SetEnvIf Request_URI "matrix\.jpg" local_ref=0 <FilesMatch "\.(png|gif|jpg)"> Order Deny,Allow Deny from all Allow from env=local_ref </FilesMatch> # Agree to play by mediaplayer or mediaplayer ONLY SetEnvIfNoCase User-Agent "RealMedia" media_ref=1 SetEnvIfNoCase User-Agent "NSPlayer" media_ref=1 SetEnvIfNoCase Request_URI "\.(mp3|wma)" is_media=1 #### My Verson #BrowserMatch "RealMedia" media_ref=0 #BrowserMatch "NSPlayer" media_ref=0 # If have been spidered by baidu or mp3searcher, you'd better rename # the file and do not use the deny. <FilesMatch "\.(mp3|wma)"> # Order Deny,Allow # Deny from all # Allow from env=media_ref </FilesMatch> ################################################### SetEnvIf Request_URI "mp3" baidu_ref=0 SetEnvIf Referer "baidu\.com" baidu_ref=0 CustomLog logs/weblog.domain.com-access_log combined env=!baidu_ref [/code:1:91367a1772] |
jackieyuan 回復于:2004-07-16 01:21:30 |
[quote:1cc91176dd="HonestQiao"] ...
上下文: 服務器配置, 虛擬主機, 目錄, .htaccess 覆蓋項: FileInfo 狀態: Base 模塊: mod_setenvif 兼容性: Apache 1.3 and above The SetEnvIfNoCase is semantically identical to the SetEnvI..........[/quote:1cc91176dd] 再讓我們試試不用阻止,而用rewrite導向錯誤從而讓百度從它的數據庫里面刪掉的方法。(如果用阻止的話,用戶會誤以為服務器忙,不停地連接,從而造成log文件快速增加。我就有一天增加180MB的經歷。如果是404錯誤,flashget會直接報錯。) [code:1:1cc91176dd] # If client use the Mozilla or Non-media explorer to download, then redirect # to a unavaluable file to response a 404(Not Found) error. ;) RewriteCond %{HTTP_USER_AGENT} !~/RealMedia/ [OR] RewriteCond %{HTTP_USER_AGENT} !~/NSPlayer/ [OR] RewriteRule mp3$ /error/HTTP_NOT_FOUND.html.var [Last][/code:1:1cc91176dd] 效果: 之前 1.直接下載的結果 2.在網頁上用播放器放的結果 之后 1.直接下載的結果 2.在網頁上用播放器放的結果 試了很多方法 用 RewriteCond %{HTTP_USER_AGENT} 也好 EnvIF 也好?。拢颍铮鳎螅澹颍停幔簦悖琛∫埠?,要么就是把 所有連接全部禁止,要么就是 全部都可以下載,請樓上版主指教~~ 到底哪里出了問題,是?。颍澹鳎颍椋簦宓模颍酰欤迥剡€是?。牛危值膯栴}。(rewriterule成功過~) :em16: |
HonestQiao 回復于:2004-07-16 12:51:56 |
客戶端的agent參數正確么? |
HonestQiao 回復于:2004-07-16 12:55:29 |
還有,你最好打開了rewritelog,然后察看rewrite的匹配過程,這樣子可以很好的分析結果,知道匹配了什么,匹配是否正確,匹配之后去做什么了? |
jackieyuan 回復于:2004-07-16 13:24:22 |
[quote:df7363400e="HonestQiao"]還有,你最好打開了rewritelog,然后察看rewrite的匹配過程,這樣子可以很好的分析結果,知道匹配了什么,匹配是否正確,匹配之后去做什么了?[/quote:df7363400e]
問題解決了一部分,以下是記錄 終結方法制止直接下載: [code:1:df7363400e]# If client use the Mozilla or Non-media explorer to download, then redirect # to a unavaluable file to response a 404(Not Found) error. ;) # This rule is not effective when it is written in TOP part(www.mydomain.com) RewriteCond %{HTTP_USER_AGENT} Mozilla|Flashget|Netants|Lynx RewriteRule .mp3$ /HTTP_NOT_FOUND.html [L][/code:1:df7363400e] 結果:在直接輸入 mp3 地址后的 log 文件: [code:1:df7363400e]221.95.221.22 - - [16/Jul/2004:10:48:53 +0800] "GET /archives/images/queen_2004.mp3 HTTP/1.1" 404 370 "http://weblog.mydomain.com/archives/images" "Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)" [Fri Jul 16 10:48:53 2004] [error] [client 221.95.221.22] File does not exist: /home/kreny/mt/weblog/HTTP_NOT_FOUND.html-, referer: http://weblog.mydomain.com/archives/images [/code:1:df7363400e] 轉向了首頁。若改為一個不存在的頁面,則可以response一個404錯誤了。注意:[color=red:df7363400e]rewrite必須寫在每個virtual hosts 才有效![/color:df7363400e] |
geel 回復于:2004-07-26 00:36:05 |
直接請求.mp3文件并且referer是baidu的直接丟掉,可以不 |
HonestQiao 回復于:2004-07-28 12:54:40 |
打開rewirte的log |
swingcoder 回復于:2004-07-29 13:57:46 |
用iptables不行嗎? |
bend 回復于:2004-07-30 17:00:34 |
我看,你們為什么不試試非apache里的東西呢?
用iptables,一句就應夠了。 iptables -A INPUT -s XXXXX(baidu ip) -p tcp -j DROP |