3/28/2013

Ubuntu下的Privoxy使用与配置同步方案

在笔记本上装了64位版的Ubuntu 12.10,第一件事就是配置如何Fuck GFW,下载Chromium。

由于流量有限,自然用Privoxy比较合适。但在修改/etc/privoxy/config的时候一不小心就把默认的config文件给覆盖了,而且还是用的Windows版本的文件。然后无论如何都不能启动/etc/init.d/privoxy start。 重装privoxy,提取源码包中的config文件都不行。

后来自己手写了一个config文件,可以勉强启动并且根据规则判断是否转发。但http://p.p/页面一直显示:

"500 Internal Privoxy Error
Privoxy encountered an error while processing your request:
Could not load template file default or one of it's
included components.
Please contact your proxy administrator.
If you are the proxy administrator, please put the
required file(s)in the (confdir)/templates directory.

这时候我强迫症发作了:用VirtualBox全新安装了一个Ubuntu,然后把默认的配置文件提取出来:点此下载(/etc/privoxy目录下的所有文件)。

对比可以发现原因是Linux和Windows下的config和config.txt不能通用。主要在于目录变量以及功能的支持上:Linux下的config默认内容:
user-manual /usr/share/doc/privoxy/user-manual
confdir /etc/privoxy
logdir /var/log/privoxy
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action   # Main actions file
actionsfile user.action      # User customizations
filterfile default.filter
filterfile user.filter      # User customizations
logfile logfile
listen-address  localhost:8118
toggle  1
enable-remote-toggle  0
enable-remote-http-toggle  0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
forwarded-connect-retries  0
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
socket-timeout 300

Windows下的config.txt默认内容:
confdir .
logdir .
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action   # Main actions file
actionsfile user.action      # User customizations
filterfile default.filter
filterfile user.filter      # User customizations
logfile logfile
listen-address  127.0.0.1:8118
toggle  1
enable-remote-toggle  0
enable-remote-http-toggle  0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
enable-proxy-authentication-forwarding 0
forwarded-connect-retries  0
accept-intercepted-requests 0
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
tolerate-pipelining 1
socket-timeout 300

最后完全重写了转发的规则,以前都是直接写在config文件里。但现在需要多平台同步,并且config文件不能通用,只好把forward规则改写成action的方式。
要感谢 七星庐:强大的代理调度器代理 Privoxy 和 cckpg的autoproxy2privoxy 的帮助。其实改写过程就几分钟,但苦在Privoxy的action功能太强大,这种简单的功能反而不知道如何下手。

然后就是把新写好的config和proxy.action文件放到Dropbox里Windows版的Privoxy目录下,再用硬链接链接到/etc/privoxy目录下。

这样Windows直接打开Dropbox中的exe程序就可以使用,Ubuntu下也可以同步到最新的规则。

但是经过多机实验,发现一个BUG,如果在Windows平台下修改proxy.action文件,会导致Ubuntu的硬链接失效。初步认为是坚果云同步文件的实现方式造成的。但由于网络环境导致Dropbox不能实时同步,所以不能确定原因。

EOF

No comments:

Post a Comment