想对代理的目标访问机器做一些限制,限制其只能够访问限定的主机。本来想修改tinyproxy的代码,一直找借口拖延,今天亮亮找我下载论文的时候,我想起这件事来。
拿出tinyproxy的代码,发现有个filter_init还有filter_url等函数,猜想tinyproxy已经有了filter功能了。
查看/etc/tinyproxy/tinyproxy.conf中:
#
# The location of the filter file.
#
#Filter "/etc/tinyproxy/filter"#
# Filter based on URLs rather than domains.
#
#FilterURLs On#
# Use POSIX Extended regular expressions rather than basic.
#
#FilterExtended On
#
# Use case sensitive regular expressions.
#
#FilterCaseSensitive On
#
# Change the default policy of the filtering system. If this directive is
# commented out, or is set to "No" then the default policy is to allow
# everything which is not specifically denied by the filter file.
#
# However, by setting this directive to "Yes" the default policy becomes to
# deny everything which is _not_ specifically allowed by the filter file.
#
#FilterDefaultDeny Yes我们可以直接设置filter来实现:只对限定站点的代理,其他的不代理。
我们修改配置文件为:
Filter "/etc/tinyproxy/filter"
FilterURLs On
FilterDefaultDeny Yes |
这样tinyproxy只能够代理filter文件中指定的URL,我们在filter文件中添写上我们的目标代理主机就可以了:
hit.edu.cn
阅读(3625) | 评论(0) | 转发(0) |