<?xml version="1.0" encoding="gb2312"?>
<rss version="2.0">
<channel>
 <title><![CDATA[华镭博客]]></title>
 <link><![CDATA[http://blog.openrays.org]]></link>
 <description><![CDATA[Latest 20 blogs of ino1]]></description>
 <copyright><![CDATA[Copyright(C) 华镭博客]]></copyright>
 <generator><![CDATA[PHPWind BLOG by PHPWind Studio]]></generator>
 <lastBuildDate><![CDATA[Sat, 19 May 2012 13:28:30 +0000]]></lastBuildDate>
  <image>
 <url><![CDATA[http://blog.openrays.org/image/rss.gif]]></url>
 <title><![CDATA[PHPWind BLOG]]></title>
 <link><![CDATA[http://blog.openrays.org]]></link>
 <description><![CDATA[华镭博客]]></description>
  </image>
<item>
 <title><![CDATA[Google Desktop for Linux With Apache2 On LAN]]></title>
 <description><![CDATA[  Google Desktop for Linux With Apache2 On LAN

前言：
 &nbsp;  在两年前第一次试作将google desktop与apache结合用于LAN的文件搜索，原文见这里《第一次原创：使用Google桌面搜索打造企业搜索服务器》[url]http://blog.chinaunix.net/u/13472/showart.php?id=73880[/url]
 &nbsp;  当时for linux的google desktop还没有出来，让我的samba文件服务器没有了集成的搜索服务可用，可谓望眼欲穿。等到for linux出来后，发现居然不支持搜索MS专有格式文档，又失望了很一段时间。终于，终于等到了google desktop for linux v1.1.1.0075,支持DOC、XLS、PPT的索引支持了，所以就捣鼓着一定要将它放置在我的samba服务器上，在提供samba服务的同时也提供一个简单的搜索服务器。
正文：
 &nbsp;  原理和前文一样，依靠apache来代理google desktop。前文中提到需要端口映射器，经过后来的搜索，原来是缺少了设置反向代理所致，即在ProxyPass后面再接一个ProxyPassReverse代理就可以避免了。所以，现在与apache结合的google desktop已经不需要客户端做任何设置了，有一个浏览器就足够了，而文件浏览器足够充当这个角色了。
 &nbsp;  如果这个apache没有其他用途，如前文，给服务器分配第2个ip专门用来处置这个google desktop代理，简单的配置文件如下：
[code]
NameVirtualHost 192.168.1.120:80
&lt;VirtualHost 192.168.1.120:80&gt;
 &nbsp; &nbsp;ServerAdmin webmaster@localhost
 &nbsp;  &nbsp;  ServerName 192.168.1.120

 &nbsp;  &nbsp;  ProxyPass // [url]http://127.0.0.1:30043/[/url]
#注：这里的30043端口每个linux用户是不同的，需要提前在桌面上记录google desktop的起始页面。
 &nbsp; &nbsp;ProxyPassReverse // [url]http://127.0.0.1:30043/[/url]
 &nbsp;  &nbsp;  &lt;Proxy [url]http://127.0.0.1:30043&gt;[/url]
 &nbsp;  &nbsp;   &nbsp; &nbsp;Allow from all

 &nbsp;  &nbsp;  &lt;/Proxy&gt;

 &nbsp; &nbsp;&lt;Directory /&gt;
 &nbsp; &nbsp; &nbsp; &nbsp;Options FollowSymLinks
 &nbsp; &nbsp; &nbsp; &nbsp;AllowOverride None
 &nbsp; &nbsp; &nbsp; &nbsp;Allow from all &nbsp; 
 &nbsp;  &nbsp;  &nbsp;  
 &nbsp; &nbsp;&lt;/Directory&gt; &nbsp; &nbsp; &nbsp; &nbsp;

 &nbsp; &nbsp;&lt;Location /redir&gt;
 &nbsp; &nbsp; &nbsp; &nbsp;Deny from all
 &nbsp; &nbsp;&lt;/Location&gt;

 &nbsp; &nbsp;&lt;Location /openfolder&gt;
 &nbsp; &nbsp; &nbsp; &nbsp;Deny from all
 &nbsp; &nbsp;&lt;/Location&gt;

&lt;/VirtualHost&gt;
[/code]
 &nbsp;  在重启apache前还需要修改apache的运行用户为google desktop的运行用户，这是因为google desktop的索引文件都是针对单个linux用户可读的，其他用户都不可读，所以用其他用户启动的apache是不能读取google desktop的数据的，也就无法代理了。
 &nbsp;  修订好这一切，apache重启后，通过[url]http://192.168.1.120/XXXXXXXX[/url]（后面省略的是google desktop的起始地址，每个linux桌面用户的都不同）就可以访问On LAN上的google desktop。
 &nbsp;  下一步，我试作将这个On LAN的google desktop集成进文件服务器，毕竟去记住那串后缀地址还是很困难的，所以有必要把这个首页文件存放在文件服务器上，通过文件服务器访问到这个文件后就可以点击首页文件打开搜索代理服务器了。
 &nbsp;  这里需要注意的是，简单的将首页保存下来的文件中由于相对地址的原因，通过文件服务器启动的首页文件不能进行搜索，所以我做了这样的改动：
[code]
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;

&quot;[url]http://www.w3.org/TR/html4/loose.dtd[/url]&quot;&gt;

&lt;html&gt;

&lt;head&gt;

&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;

&lt;meta http-equiv=&quot;cache-control&quot; content=&quot;no-cache&quot;&gt;

&lt;meta http-equiv=&quot;pragma&quot; content=&quot;no-cache&quot;&gt;

&lt;meta http-equiv=&quot;expires&quot; content=&quot;-1&quot;&gt;

&lt;title&gt;Google 桌面&lt;/title&gt;

&lt;style&gt;

body,p,td{font-family:arial,sans-serif;color:#000}body{background-color:#fff;margin:4px}img{border:0}table,td{border:0;margin:0;padding:0}.nowrap{white-space:nowrap}.none{display:none}.inline{display:inline}.float_left{float:left}.logo3{margin-top:9px;padding-bottom:10px}a:visited{color:#551a8b}a:link{color:#00c}a:active{color:#00c}a:hover{color:#00c}

.q{color:#00c;padding:4px 0 4px 4px;margin:0;white-space:nowrap}.q a:visited{color:#00c}.q a:link{color:#00c}.q a:hover{color:#00c}.q a:active{color:#00c}span{margin:0px}div{border:0;margin:0;padding:0}div#basic{margin:7px}div#advanced{margin:7px}div#search_box{padding-top:30px;padding-bottom:30px}div#line{background-color:#39c;height:1px}div#bottomquery{background-color:#e8f4f7}

div#querybuttons{padding-top:20px;padding-bottom:20px;text-align:center}div#bottom_links{text-align:center;font-size:small;padding-bottom:80px;white-space:nowrap}p#copyright{padding-top:3px;font-size:x-small;white-space:nowrap}div#home_bottom span#homelink{display:none}div#pref_bottom div#bottom_links{padding-bottom:10px}h1{color:#335cec;font-size:large;font-weight:bold}

div.centerwarning{text-align:center}h4#fixmsg,h4#lowdisk{color:#f60}

input#q { margin-bottom:1px }

div#idxprogress {

text-align: center;

color: #f60;

}

h4#idxongoing {

padding-top: 5px;

padding-bottom: 5px;

}

&lt;/style&gt;

&lt;script&gt;

&lt;!--

function sf() {

document.f.q.focus();

}

function sw() {

window.location = &quot;[url]http://www.google.com/search?sourceid=GGXD&rlz=1L1GGXD&hl=zh-CN&oe=UTF-8&sa=N&tab=xw&q=[/url]&quot; + encodeURIComponent(document.f.q.value);

}

--&gt;

&lt;/script&gt;

&lt;/head&gt;

&lt;body onLoad=sf()&gt;

&lt;center&gt;

&lt;br&gt;

&lt;img src=&quot;image/hp-logo.gif?hl=zh_CN&quot;

width=276 height=110 alt=&quot;Google 桌面&quot;&gt;

&lt;br&gt;&lt;br&gt;

&lt;form name=f action=&quot;[url]http://192.168.1.120/search[/url]&quot; method=get&gt;

&lt;input type=&quot;hidden&quot; name=&quot;hl&quot; value=&quot;zh_CN&quot;&gt;

&lt;input type=&quot;hidden&quot; name=&quot;s&quot; value=&quot;IKfIRNbuy8oqOJPMZBNzffceB6c&quot;&gt;

&lt;div class=&quot;q&quot;&gt;

&lt;style&gt;TD.q {white-space: nowrap}&lt;/style&gt;&lt;style&gt;#lgpd{display:none}&lt;/style&gt;&lt;script defer&gt;&lt;!--
function qs(el){if(window.RegExp&&window.encodeURIComponent){var ue=el.href,qe=encodeURIComponent(document.f.q.value);if(ue.indexOf(&quot;q=&quot;)!=-1){el.href=ue.replace(new RegExp(&quot;q=[^&$]*&quot;),&quot;q=&quot;+qe);}else{el.href=ue+&quot;&q=&quot;+qe;}}return 1;}
//--&gt;
&lt;/script&gt;&lt;table border=0 cellspacing=0 cellpadding=4&gt;&lt;tr&gt;&lt;td nowrap&gt;&lt;font size=-1&gt;&lt;a class=q href=&quot;[url]http://www.google.com/webhp?source_id=GGXD&rlz=1L1GGXD&hl=zh-CN&oe=UTF-8&q=GOOOOG&tab=xw[/url]&quot; onclick=&quot;return qs(this)&quot;&gt;网页&lt;/a&gt; &nbsp;  &lt;a class=q href=&quot;[url]http://images.google.com/imghp?source_id=GGXD&rlz=1L1GGXD&hl=zh-CN&oe=UTF-8&q=GOOOOG&tab=xi[/url]&quot; onclick=&quot;return qs(this)&quot;&gt;图片&lt;/a&gt; &nbsp;  &lt;a class=q href=&quot;[url]http://groups.google.com/grphp?source_id=GGXD&rlz=1L1GGXD&hl=zh-CN&oe=UTF-8&q=GOOOOG&tab=xg[/url]&quot; onclick=&quot;return qs(this)&quot;&gt;论坛&lt;/a&gt; &nbsp;  &lt;a class=q href=&quot;[url]http://news.google.com/nwshp?source_id=GGXD&rlz=1L1GGXD&hl=zh-CN&oe=UTF-8&q=GOOOOG&tab=xn[/url]&quot; onclick=&quot;return qs(this)&quot;&gt;资讯&lt;/a&gt; &nbsp;  &lt;a class=q href=&quot;[url]http://ditu.google.com/maps?source_id=GGXD&rlz=1L1GGXD&hl=zh-CN&oe=UTF-8&q=GOOOOG&tab=xl[/url]&quot; onclick=&quot;return qs(this)&quot;&gt;地图&lt;/a&gt; &nbsp;  &lt;b&gt;桌面&lt;/b&gt; &nbsp;  &lt;!--ENTERPRISE--&gt;&lt;b&gt;&lt;a href=&quot;[url]http://www.google.com/intl/zh-CN/options/[/url]&quot; class=q&gt;更多 &raquo;&lt;/a&gt;&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;

&lt;table cellspacing=0 cellpadding=0&gt;&lt;tr&gt;&lt;td width=25%&gt; &lt;/td&gt;

&lt;td align=center&gt;

&lt;input id=&quot;q&quot; maxlength=512 size=55 name=q value=&quot;&quot; title=&quot;Google 桌面&quot;&gt;&lt;br&gt;

&lt;input type=submit value=&quot;搜索桌面&quot;&gt;

&lt;input type=button value=&quot;搜索网络&quot; onclick=sw()&gt;

&lt;/td&gt;

&lt;td valign=top nowrap width=25%&gt;&lt;font size=-2&gt;

  &lt;a href=&quot;[url]http://192.168.1.120/options?hl=zh_CN&s=KfaPHSQRTXpTQAiCn0SSk8QuG2U[/url]&quot;&gt;桌面使用偏好&lt;/a&gt;&lt;br&gt;

  &lt;a href=&quot;[url]http://192.168.1.120/adv?hl=zh_CN&s=RInjEvQpp_ec0xuHJfV2RMld_nM[/url]&quot;&gt;高级搜索&lt;/a&gt;&lt;br&gt;

&lt;/font&gt;&lt;/td&gt;

&lt;/tr&gt;&lt;/table&gt;

&lt;/form&gt;

&lt;br&gt;

&lt;div class=&quot;centerwarning&quot;&gt;

&lt;br&gt;



&lt;/div&gt;



&lt;br&gt;

&lt;div id=&quot;home_bottom&quot;&gt;

&lt;div id=&quot;bottom_links&quot;&gt;

&lt;span id=&quot;homelink&quot;&gt;

Google 桌面主页

- 

&lt;/span&gt;

&lt;a href=&quot;[url]http://192.168.1.120/status?hl=zh_CN&s=1lSl07UkINdDG1B8XKs5981ICpM[/url]&quot;&gt;索引状态&lt;/a&gt;

- 

&lt;a href=&quot;[url]http://192.168.1.120/privacy?hl=zh_CN&s=7MTauqWsrjfyih2nmolpmXA1mfc[/url]&quot;&gt;隐私权&lt;/a&gt;

- 

&lt;a href=&quot;[url]http://192.168.1.120/about?hl=zh_CN&s=9H5yl44biBXVBAjJUC77vy7RfPY[/url]&quot;&gt;关于&lt;/a&gt;

&lt;p id=&quot;copyright&quot;&gt;&copy;2007 Google&lt;/p&gt;

&lt;/div&gt;

&lt;/div&gt;

&lt;/center&gt;

&lt;/body&gt;

&lt;/html&gt;
[/code]
上面含有的“[url]http://192.168.1.120[/url]”字串都是我改动添加上去的，如此启动的首页文件便可以触发搜索代理服务器。

 &nbsp;  我的基本要求达到后，还是没有达到我的预期。因为我的服务器本身启用apache的原因是为了提供samba文件服务器的跨网段web访问，所以前面那个首页文件也可以被原来的apache访问到，但是却不能提供搜索服务（我的ip地址有限，不能够把内网地址全部映射出去的）。所以，接下来，对上面的设置适当加以改造，让它适合互联网应用。
 &nbsp;  显然，不能代理成根目录了，因为根目录要用来当作文件服务器的首页，所以就把它代理到/googlesearch，所以代理部分的内容就变成了：
[code]
 &nbsp;  &nbsp;  ProxyPass /googlesearch/ [url]http://127.0.0.1:30043/[/url]
 &nbsp; &nbsp;ProxyPassReverse /googlesearch/ [url]http://127.0.0.1:30043/[/url]
 &nbsp;  &nbsp;  &lt;Proxy [url]http://127.0.0.1:30043&gt;[/url]
 &nbsp;  &nbsp;   &nbsp; &nbsp;Allow from all
 &nbsp;  &nbsp;  &lt;/Proxy&gt;

 &nbsp; &nbsp;&lt;Location /googlesearch／redir&gt;
 &nbsp; &nbsp; &nbsp; &nbsp;Deny from all
 &nbsp; &nbsp;&lt;/Location&gt;

 &nbsp; &nbsp;&lt;Location /googlesearch/openfolder&gt;
 &nbsp; &nbsp; &nbsp; &nbsp;Deny from all
 &nbsp; &nbsp;&lt;/Location&gt;
[/code]
 &nbsp;  这样的代理可以打开主页但是根本不能展开搜索，原因是google desktop启动搜索的时候的url地址都是从根/search开始的，所以，需要进行URL重写，如下：
[code]
 &nbsp;  &nbsp;  RewriteEngine On
 &nbsp; &nbsp;&lt;Directory /Fileserver&gt;
#  /Fileserver目录是DocumentRoot目录；
 &nbsp; &nbsp; &nbsp; &nbsp;Options Indexes FollowSymLinks MultiViews
 &nbsp; &nbsp; &nbsp; &nbsp;AllowOverride None
 &nbsp; &nbsp; &nbsp; &nbsp;Order allow,deny
 &nbsp; &nbsp; &nbsp; &nbsp;allow from all
 &nbsp;  &nbsp;  &nbsp;  &nbsp;   RedirectMatch ^/search /googlesearch/search
 &nbsp; &nbsp;&lt;/Directory&gt;
[/code]
 &nbsp;  终于，google desktop被集成进apache了。最后一步，修改主页文件，另存为/Fileserver/文件搜索/目录下的index.html，以保证apache访问到该目录时直接打开首页文件。
 &nbsp;  首页文件的修改很简单，把上面的[url]http://192.168.1.120[/url]全部替换成“/googlesearch”就可以了。

尾注：
 &nbsp;  目前残留的问题就是将搜索出来的文件打开的问题，上面的处理都是简单的屏蔽，要实现如DNKA一般的效果需要采用输出重新，我这里简单把mod_sar的说明贴在这儿。
[quote]
NAME
mod_sar - apache2 module which works as output filter and it&#39;s
 &nbsp;  &nbsp;  &nbsp;  purpose is to Search And Replace strings found in web
 &nbsp;  &nbsp;  &nbsp;  content before it&#39;s sending to the client.


COMPILE
mod_sar can be compiled with apxs(8) or manually by hand.

1. Using apxs for compilation:
apxs -c mod_sar.c

If everything goes fine, you will find mod_sar.so under .libs in your
current directory.

2. Compiling mod_sar manually:
gcc -pthread -I/usr/include/httpd -c mod_sar.c
gcc -shared mod_sar.o -Wl,-soname -Wl,mod_sar.so -o mod_sar.so

If needed, modify path to your httpd include directory and if everything
goes fine, you will find mod_sar.so in your current directory.


INSTALL
mod_sar can be installed with apxs(8) or manually by hand.

1. Using apxs for instalation:
This command will compile and install your mod_sar module.
apxs -i -a -c mod_sar.c

Restart apache by first stopping it and then starting it:
apachectl stop
apachectl start

2. Installing mod_sar manually:
cp mod_sar.so /usr/lib/httpd/modules
chown root: /usr/lib/httpd/modules/mod_sar.so
chmod 755 /usr/lib/httpd/modules/mod_sar.so

If needed, modify path to your httpd modules directory.
Now, you have to modify your httpd.conf file. Find the bunch of
LoadModule directives and append your own line under them:
LoadModule sar_module modules/mod_sar.so

Restart apache by first stopping it and then starting it:
apachectl stop
apachectl start


DESCRIPTION
mod_sar (&quot;sar&quot; stands for Search And Replace) is apache2 module which
works as output filter. It&#39;s purpose is to search and replace strings
found in web content before it&#39;s sending to the client.
Search performed can be case sensitive or case insensitive, depending
on configuration.
Perfect example of common usage of this module is reverse proxy.

Reverse proxy is proxy in front of the local server, which can be
accessed from Internet only trough that proxy. In some cases such
configuration can be used effectively to prevent worms and other
unwanted guests but most commonly it just present a false layer of
security for those who do not understand server - client communication.

Whatever reason you have, for usable reverse proxy you will have to
solve two problems: modification of headers and modification of
content before it&#39;s sending to client.

1. Header modification
Header modification is not problem at all. It can be achieved two
ways.
You can use mod_proxy_http:
 &nbsp;  &lt;IfModule mod_proxy.c&gt;
 &nbsp;  &nbsp;   &lt;Proxy *&gt;
 &nbsp;  &nbsp;  &nbsp;  &nbsp; Order deny,allow
 &nbsp;  &nbsp;  &nbsp;  &nbsp; Allow from all
 &nbsp;  &nbsp;   &lt;/Proxy&gt;
 &nbsp;  &nbsp;   ProxyRequests On
 &nbsp;  &nbsp;   ProxyPass / [url]http://some-domain.local/[/url]
 &nbsp;  &nbsp;   ProxyPassReverse / [url]http://some-domain.local/[/url]
 &nbsp;  &nbsp;   ProxyErrorOverride On
 &nbsp;  &lt;/IfModule&gt;
Or, you can use mod_rewrite:
 &nbsp;  &lt;IfModule mod_rewrite.c&gt;
 &nbsp;  &nbsp;   RewriteEngine on
 &nbsp;  &nbsp;   RewriteRule ^/(.*) [url]http://some-domain.local/$1[/url] [P]
 &nbsp;  &nbsp;   RewriteOptions inherit
 &nbsp;  &lt;/IfModule&gt;

2. Content modification
Header modification will make all relative links look like they are
coming from external domain some-domain.com instead of real, local
domain some-domain.local. But if server behind reverse proxy the
serves pages with absolute links, we will have to modify content of
that pages on the fly, using apache2 output filter mechanism.

There are three choices: mod_proxy_html, mod_ext_filter and mod_sar.
The first uses a libxml2 and because of that, it is not good for
purpose such as reverse proxy. For example, libxml2 will seriously
corrupt HTML code in case of a minor errors in HTML such as missing
quote. mod_proxy_html inherits that nasty habit from libxml2 but
if you want to try it your own, you can find that module at
[url]http://apache.webthing.com/mod_proxy_html/[/url]
The second one is not a third party module, it comes with apache2
and it can suite needs for reverse proxy but it is not good for heavy
loaded sites because external command is executed for every request.
Here is example of mod_ext_filter usage:
 &nbsp;  &lt;IfModule mod_ext_filter.c&gt;
 &nbsp;  &nbsp;   ExtFilterDefine fixtext mode=output intype=text/html \\
 &nbsp;  &nbsp;  &nbsp;  &nbsp; cmd=&quot;/bin/sed s/some-domain\\.local/some-domain\\.com/g&quot;
 &nbsp;  &nbsp;   &lt;Location /&gt;
 &nbsp;  &nbsp;  &nbsp;  &nbsp; SetOutputFilter fixtext
 &nbsp;  &nbsp;   &lt;/Location&gt;
 &nbsp;  &lt;/IfModule&gt;
And the third one is the one you are just looking at: mod_sar.
See the DIRECTIVES and EXAMPLES sections for usage information.
mod_sar will do one simple thing. It will replace one string
with another, depending on configuration. It can perform case
insensitive search if needed. It has been tested under heavy load
without performance impact.


DIRECTIVES
SarStrings &lt;search_string&gt; &lt;replace_string&gt;
 &nbsp;  &nbsp;  This directive requires two parameters, search string and
 &nbsp;  &nbsp;  replace string enclosed with double quotes.
 &nbsp;  &nbsp;  It can be used in server config and virtual host context.

SarCaseInsensitive &lt;On|Off&gt;
 &nbsp;  &nbsp;  If set to On, case insensitive search will be performed instead
 &nbsp;  &nbsp;  of exact string match.
 &nbsp;  &nbsp;  Default is Off.
 &nbsp;  &nbsp;  It can be used in server config and virtual host context.

SarVerbose &lt;On|Off&gt;
 &nbsp;  &nbsp;  If set to On, every time mod_sar is used as filter, message is
 &nbsp;  &nbsp;  printed into apache error logs.
 &nbsp;  &nbsp;  Default is Off.
 &nbsp;  &nbsp;  It can be used in server config and virtual host context.


EXAMPLES
 &nbsp;  &nbsp;  &lt;IfModule mod_sar.c&gt;
 &nbsp;  &nbsp;  &nbsp;   AddOutputFilterByType sar_filter text/html
 &nbsp;  &nbsp;  &nbsp;   SarStrings &quot;[url]http://some-domain.local[/url]&quot; &quot;http//some-domain.com&quot;
 &nbsp;  &nbsp;  &nbsp;   SarCaseInsensitive Off
 &nbsp;  &nbsp;  &nbsp;   SarVerbose Off
 &nbsp;  &nbsp;  &lt;/IfModule&gt;


REQUIREMENTS
Apache-2.0.


COMPATIBILITY
It has been tested on Linux but there is no obvious reason why it
would&#39;n work on other unix platforms supported by apache2.
 &nbsp;  &nbsp;  &nbsp;  &nbsp;  OS:  Linux
 &nbsp;  &nbsp;  compiler:  gcc-2.9x, gcc-3.x
 &nbsp;  &nbsp;  &nbsp; apache:  apache-2.0.x


BUGS
Current version of mod_sar does not contain known bugs.


SEE ALSO
apxs(8), [url]http://www.apache.org/[/url]


AUTHOR
Josip Deanovic &lt;[email]djosip@linuxpages.org[/email]&gt;
[/quote]
 &nbsp;  由于新版本的google desktop的输出url规则比较复杂，重写很困难，加上linux文件系统中太多的权限，许多目录都不会允许apache访问的,所以就懒得再折腾了，毕竟输出的信息中已经有文件位置的详细地址，通过文件服务器找寻下去也是很方便的。
 &nbsp;  最后，希望看到这篇文章的达人能够帮助写出mod-sar的输出规则，帮我完善这个Google Desktop For Linux with Apache2 On LAN,谢谢。]]></description>
 <link><![CDATA[http://blog.openrays.org/blog.php?do=showone&tid=476]]></link>
 <author><![CDATA[ino1]]></author>
 <category><![CDATA[华镭社区博客]]></category>
 <pubdate><![CDATA[Wed, 26 Mar 2008 22:11:01 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[[转帖]VirtualBox网络配置详解]]></title>
 <description><![CDATA[[转帖]VirtualBox网络配置详解
欢迎转载, 转载请注明作者, 谢谢

下面简单介绍一下Test-bed Environment:

Host : 偶的本本
OS : Arch Linux (Kernel Version 2.6.20) 已安装uml_utilities(包含tunctl工具)和bridge-utils(包含brctl工具)两个包.
Username : leemars
LAN IP : 192.168.1.106/24
Interface : ath0

Guest : 偶的本本上的一个虚拟机
OS : Win2003
Host Interface : tap0

Non-Host : 偶的台式机
OS : WinXP
LAN IP : 192.168.1.120/24

Wireless Router:
LAN IP : 192.168.1.1/24 Gateway
WAN IP : 172.18.60.55/24 绑定MAC
Router开启了DHCP

Network Environment :
Non-Host直接接在无线路由上, Host通过无线网卡与无线路由连接. 无线路由开启了DHCP功能.

===================================

最简单的方案 : NAT(by VirtualBox)

Host :
直接使用VirtualBox提供的NAT功能.

Guest :
网卡设置为使用DHCP.

Guest -&gt; WAN :
由VirtualBox的NAT提供WAN的访问服务.

Guest -&gt; Host :
需要注意的是, 如果直接访问Guest拿到的网关IP, 会发现这个IP似乎是Host. 不过事实上不能直接访问网关IP来访问Host. 因为这个IP是由VirtualBox负责的, 只实现了NAT的功能, 其他的一些功能并不能正常运行(如FTP). 如果要访问Host, 应该访问Host的真实IP.

Host -&gt; Guest :
不可访问. 虽然VirtualBox的NAT功能中包括了Port Forwarding的功能, 但截至到1.3.6 Snapshot, 这个功能仍没有出现在GUI中. 不过在OSE Version中已经可以使用这个功能. 通过Port Forwarding可以实现部分的向内访问.

VirtualBox NAT没有什么玩法了. 下面的方案都是使用VirtualBox的Host Interface功能.

-----------------------------------------------------------------------------
方案一 : NAT(by Linux) + Route

Host :
#echo 1 &gt; /proc/sys/net/ipv4/ip_forward #打开转发功能
#iptables -t nat -A POSTROUTING -j MASQUERADE #利用iptables完成NAT功能

#chmod 0666 /dev/net/tun #设置访问权限
#tunctl -t tap0 -u leemars #建立一个tap设备, 名字为tap0, 所有者为leemars
#ifconfig tap0 up #激活tap0
#ifconfig tap0 10.10.10.1 netmask 255.255.255.0 #为tap0指定IP和网段, 为10.10.10.1/24.

Guest :
网卡设置如下:
IP : 10.10.10.10
Netmask : 255.255.255.0
Gateway : 10.10.10.1

Guest -&gt; WAN :
由Linux的iptables完成NAT功能, 提供WAN的访问服务.

Guest -&gt; Host :
10.10.10.1是真实的Host. Guest对Host的任何访问都可以通过访问10.10.10.1来完成.

Host -&gt; Guest :
10.10.10.10是真实的Guest. Host对Guest的任何访问都可以通过访问10.10.10.10来完成.

Non-Host -&gt; Guest :
因为Guest是在Host的NAT之后的一个私有子网中, 所以直接访问是不行的. 不过可以通过iptables来完成Port Forwarding, 实现部分的向内访问.

-----------------------------------------------------------------------------

方案二 : Transparent Bridge (Layer 2)

在我的机器上测试下来的结果很遗憾, 无线网卡似乎不能配合Bridge工作. 建好Bridge之后, Guest只能访问Host, 连网关都访问不到. 所以我改用有线网卡来进行测试, 有线网卡为eth0, IP地址同ath0.

Host :

#chmod 0666 /dev/net/tun #设置访问权限
#tunctl -t tap0 -u leemars #建立一个tap设备, 名字为tap0, 所有者为leemars

#ifconfig eth0 0.0.0.0 promisc #使eth0进入promiscuous模式
#ifconfig tap0 0.0.0.0 promisc #使tap0进入promiscuous模式
#brctl addbr br0 #增加一个网桥
#brctl addif br0 eth0 #将eth0加入网桥
#ifconfig eth0 up #激活eth0
#dhclient br0 #为br0设置IP地址
#brctl addif br0 tap0 #将tap0加入网桥
#ifconfig tap0 up #激活tap0

Guest :
网卡设置为DHCP. 或者在设置为Host的Subnet中的一个IP地址, 如下例:
IP : 192.168.1.201
Netmask : 255.255.255.0
Gateway : 192.168.1.1

Guest -&gt; WAN :
由网关提供WAN的访问服务.

Guest -&gt; Host :
直接访问Host的IP地址即可.

Host -&gt; Guest :
直接访问Guest的IP地址即可.

Non-Host -&gt; Guest :
直接访问Guest的IP地址即可.
(由于建立了eth0和tap0的Bridge, Non-Host的ARP包被eth0接收到后, 被Brideg转发至tap0上, 数据链路得以建立.)

-----------------------------------------------------------------------------

方案三 : Transparent IP (Layer 3) proxy ARP bridge (by parprouted)

Host :
#echo 1 &gt; /proc/sys/net/ipv4/ip_forward #打开转发功能

#chmod 0666 /dev/net/tun #设置访问权限
#tunctl -t tap0 -u leemars #建立一个tap设备, 名字为tap0, 所有者为leemars
#ip link set tap0 up #激活tap0
#ip addr add 169.1.1.1/32 dev tap0 #为tap0任意指定一个私有地址
#parprouted [-d] ath0 tap0 #启动parprouted监听ath0和tap0. -d参数为Debug模式

Guest :
网卡设置如下:
IP : 192.168.1.201
Netmask : 255.255.255.0
Gateway : 192.168.1.1

Guest -&gt; WAN :
由网关来提供WAN的访问服务.

Guest -&gt; Host :
直接访问Host的IP地址即可.

Host -&gt; Guest :
直接访问Guest的IP地址即可.

Non-Host -&gt; Guest :
直接访问Guest的IP地址即可.

Troubleshooting:
这个parprouted软件有时会出现无法连通的情况. 这时可以尝试更换Guest的IP地址来解决问题. 这个貌似是parprouted软件的BUG.

-----------------------------------------------------------------------------

方案四 : ARP Proxy(by Linux) + Route

Host :
#echo 1 &gt; /proc/sys/net/ipv4/ip_forward #打开转发功能

#chmod 0666 /dev/net/tun #设置访问权限
#tunctl -t tap0 -u leemars #建立一个tap设备, 名字为tap0, 所有者为leemars
#ip link set tap0 up #激活tap0
#route add -host 192.168.1.201 dev tap0 #增加一个路由, 将192.168.1.201定向到tap0
#echo 1 &gt; /proc/sys/net/ipv4/conf/ath0/proxy_arp #打开ath0上的ARP Proxy
#echo 1 &gt; /proc/sys/net/ipv4/conf/tap0/proxy_arp #打开tap0上的ARP Proxy

Guest :
网卡设置如下:
IP : 192.168.1.201
Netmask : 255.255.255.0
Gateway : 192.168.1.1

Guest -&gt; WAN :
由网关来提供WAN的访问服务.

Guest -&gt; Host :
直接访问Host的IP地址即可.

Host -&gt; Guest :
直接访问Guest的IP地址即可.

Non-Host -&gt; Guest :
直接访问Guest的IP地址即可.

作者：leemars（linuxsir论坛）

原文位于：[url]http://www.linuxsir.org/bbs/showthread.php?t=293771[/url]]]></description>
 <link><![CDATA[http://blog.openrays.org/blog.php?do=showone&tid=287]]></link>
 <author><![CDATA[ino1]]></author>
 <category><![CDATA[华镭社区博客]]></category>
 <pubdate><![CDATA[Fri, 02 Mar 2007 19:21:20 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[我来总结virtualbox的安装及常见问题吧]]></title>
 <description><![CDATA[<span class=\"tpc_title\">我来总结virtualbox的安装及常见问题吧</span><br /><br /><span class=\"tpc_content\">一 安装：<br />1 准备安装包：<br />  到官方站点下载ubuntu dapper的安装包，点击<a target=\"_blank\" href=\"http://www&#46;virtualbox&#46;org/download/1&#46;3&#46;6/VirtualBox_1&#46;3&#46;6_Ubuntu_dapper_i386&#46;deb\"><font color=\"crimson\">这里</font></a>；<br />  下载安装需要的两个依赖包，<a target=\"_blank\" href=\"http://forum&#46;openrays&#46;org/job-htm-action-download-pid-16565-tid-4206-aid-946&#46;html\"><font color=\"crimson\">这里是libpng12-0</font></a>，<a target=\"_blank\" href=\"http://forum&#46;openrays&#46;org/job-htm-action-download-pid-16565-tid-4206-aid-947&#46;html\"><font color=\"crimson\">这里是libqt3-mt</font></a>； <br /><br />2 安装rays内核头文件：<br />  #uname -r 得到内核版本号；<br />  #sudo apt-get install linux-headers-版本号(注意去掉最后CPU类型如-686)；<br /><br />3 安装刚才准备好的deb包：<br />  #sudo dpkg -i *&#46;deb<br />  #sudo apt-get -f install （安装欠缺的依赖包）<br />  如果没看见提升virtualbox安装成功的提示，可能还需要再次 sudo dpkg -i *&#46;deb，主要需要先解决依赖问题；<br /><br />4 将需要运行virtualbox的用户添加到vboxusers用户组中：<br />  直接在控制中心用图形界面就可以搞定的。<br />  注销桌面，重新登录，使刚才添加用户生效；<br /><br />5 在系统-系统工具下面出现有Innotek VirtualBox菜单，点击就开始运行virtualbox了。<br /><br />二 已知常见问题：<br />1Q 不能运行，即点击virtualbox后没反应；<br /> A 已知都是内核模块没加载，运行命令<div style=\"font-size: 9px; margin-left: 5px;\"><b>CODE:</b></div><div id=\"code1\" class=\"quote\"><br /> &#160; #dmesg | grep vboxdrv<br /> &#160; # vboxdrv: disagrees about version of symbol struct_module</div><br /> &#160; 产生原因是进行了内核或者头文件单一升级，造成头文件与内核不符合，直接强制加载内核模块即可解决：<br /> &#160; <div style=\"font-size: 9px; margin-left: 5px;\"><b>CODE:</b></div><div id=\"code2\" class=\"quote\">sudo modprobe -f vboxdrv</div><br /> &#160; 使用这样的方式要求每次host开机后都要手动运行一次，很不方便，要使内核与模块相符合，可以：<br /> &#160; 1 如果你只是进行了头文件升级，只需要再次升级内核就可以了；<br /> &#160; 2 如果是升级的内核，需要先更新头文件后重新安装VirtualBox。<br /><br />2Q 终端运行VirtualBox命令出现COM权限错误；<br /> A 主要产生原因是不是用deb包安装而是用run包安装后，第一次使用时就 sudo VirtualBox命令运行造成在用户目录下的配置文件被修改成root了。可以手动修改权限回来，但是建议重新安装deb包；<br /><br />3Q 不知道如何与主机通信；<br />AVirtualBox主要采用smb与主机通信，缺省采用NAT的方式，自带DHCP服务，因此客户端不要要进行任何设置。默认得到的客户端ip是10&#46;0&#46;2&#46;15,网关是10&#46;0&#46;2&#46;2,DNS是10&#46;0&#46;2&#46;3，可以手动如此修改。但是，一般只要重启一次主机后自带的DHCP就会生效的。对主机资源采用smb方式进行共享，需要采用\\ip地址（主机的ip地址）的方式访问；<br /> &#160;其实，VirtualBox本身还带有一个虚拟的小型局域网络，提供额外的smb服务，即程序VBoxManage,使用该命令行的方式可以指定host的目录共享给guest机,主机被虚拟成netbios名为vboxsvr,客户机通过访问 \\\\vboxsvr\\共享名获得读写共享，但是这种共享方式很麻烦，没有直接host开启smb来得方便。为简化这种共享，网友huangjiahua（ubuntu中国）特地制作了一个配置软件，点击<a target=\"_blank\" href=\"http://archive&#46;ubuntu&#46;org&#46;cn/ubuntu-cn/dists/dapper/main/binary-i386/virtualbox/vboxsharedfolder_1&#46;3&#46;6_dapper_all&#46;deb\"><font color=\"crimson\">这里</font></a>获得deb安装包。注意的是，安装后的菜单也在系统工具下面，配置共享前guest不能开启。<br /><br />4Q 运行QQ跳出guest机；<br /> A QQ键盘加密问题，和vista一样，临时解决方式也一样；<br /><br />5Q 不能用USB设备；<br /> A 由于系统自身usbfs权限限制，需要root权限运行VirtualBox才能加载USB设备；即需要<div style=\"font-size: 9px; margin-left: 5px;\"><b>CODE:</b></div><div id=\"code3\" class=\"quote\"> sudo VirtualBox</div>方式来启动程序；<br /> &#160; 参考<a target=\"_blank\" href=\"http://www&#46;cslog&#46;cn/Content/ubuntu_virtualbox_usb_dev&#46;html\">[url]http://www&#46;cslog&#46;cn/Content/ubuntu_virtualbox_usb_dev&#46;html[/url]</a>，发现只要只要赋予普通用户usbfs权限，也是可以直接启用的usb的，即在/etc/fstab文件中添加如下一行自动挂载：<br /> &#160; <div style=\"font-size: 9px; margin-left: 5px;\"><b>CODE:</b></div><div id=\"code4\" class=\"quote\">none /proc/bus/usb usbfs devgid=1000,devmode=664 0 0</div><br /> &#160; 注意，并不需要添加usbfs组，直接使用一个已经存在的用户组就行了。如果你桌面一般只有一个用户，使用gid=1000的用户组就是你的第一个用户的自身组。使用devmode=666就可以使得任意用户都有了usbfs的使用权限了。<br /> &#160; 还要注意，由于usbfs之前已经被挂载了，所以需要重启host。<br /><br />6Q 如何设置桥接模式网络；<br /> A 虽然VirtualBox自带的NAT模式网络已经很好了，但要把guest机加入host机的网络，就需要桥接模式，这里网友leemars（linuxsir论坛） 作了详细阐述，出于方便查找和收藏，我放在blog里面了，看这里：<a target=\"_blank\" href=\"http://blog&#46;openrays&#46;org/blog-htm-do-showone-tid-287&#46;html\">[url]http://blog&#46;openrays&#46;org/blog-htm-do-showone-tid-287&#46;html[/url]</a><br /> &#160; 关于桥接模式自动运行，把在另外一个帖子的解决办法也贴在这里：<br /> &#160; 使用blog里面的第2中方法：<br /> &#160; 先建立一个脚本文件，比如<br /> &#160; sudo gedit /etc/init&#46;d/VBoxBridgedRun<br /> &#160; 将那段代码写入，然后 sudo chmod 755 /etc/init&#46;d/VBoxBridgedRun<br /> &#160; 再建立一个脚本文件<br /> &#160; sudo gedit /etc/init&#46;d/VBoxBridged<br /> &#160; 写入这行代码：<br /> &#160; /etc/init&#46;d/VBoxBirdgedRun &amp;<br /> &#160; 即：让那段代码在后台运行。<br /> &#160; 后面就是将后一个文件链接到rc2&#46;d文件夹中，最好放在最后，即S9999VBoxBridged之类；<br /><br />至此，我的能力有限了，期待大家补充！<br /></span>]]></description>
 <link><![CDATA[http://blog.openrays.org/blog.php?do=showone&tid=280]]></link>
 <author><![CDATA[ino1]]></author>
 <category><![CDATA[华镭社区博客]]></category>
 <pubdate><![CDATA[Thu, 01 Mar 2007 22:34:34 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[实在是喜欢beryl的窗口管理器了！]]></title>
 <description><![CDATA[  升级后的beryl，窗口管理器实在霸道：

鼠标移动到左上角：将当前窗口移动到左桌面；
鼠标移动到右下角：将当前窗口移动到右桌面；
鼠标移动到左下角：最小化桌面上所有窗口，显示桌面；再重复一次，显示之前的桌面；
鼠标移动到右上角：列出全部窗口，等待选择；

^_^，只需要轻轻移动鼠标，一切都那么流畅！

演示文件在这儿[url]http://forum.openrays.org/job-htm-action-download-pid-15121-tid-3971-aid-835.html[/url]]]></description>
 <link><![CDATA[http://blog.openrays.org/blog.php?do=showone&tid=227]]></link>
 <author><![CDATA[ino1]]></author>
 <category><![CDATA[华镭社区博客]]></category>
 <pubdate><![CDATA[Wed, 10 Jan 2007 11:18:18 +0000]]></pubdate>
</item>
<item>
 <title><![CDATA[^_^，原来修正到50贴就开通嗦]]></title>
 <description><![CDATA[那就开通呗，谁叫我这几天发帖量还不错嘛。]]></description>
 <link><![CDATA[http://blog.openrays.org/blog.php?do=showone&tid=187]]></link>
 <author><![CDATA[ino1]]></author>
 <category><![CDATA[华镭社区博客]]></category>
 <pubdate><![CDATA[Fri, 15 Dec 2006 13:04:40 +0000]]></pubdate>
</item>
</channel></rss>
