相信很多人和我一样有个VPS,装个windows,再来个ccproxy就可以“科学上网了”,但是有如下问题:

1,ccproxy是商业软件,不付费的话,只能有3个用户的授权,自己用当然没问题,但是如果给家人和朋友发账号,那明显不够

2,权限控制不灵活

3,squid的http代理性能非常高,这一点我以前做cdn的时候测试过,哪怕是在本机,通过squid和直接请求网页的话,性能差距可以有几倍!

 

 

近日我也无聊,将ccproxy删掉换成了squid,各种爽,呵呵,各位随我来:

首先,下载windows版的squid,解压,我这里的路径是c:\service\squid

下载页面:

http://squid.acmeconsulting.it/download/dl-squid.html

我用的是最新的2.7稳定版:http://squid.acmeconsulting.it/download/squid-2.7.STABLE8-bin.zip

注意,squid 3.x和2.x的配置区别非常大,可以说整个体系都大改了,所以如果你无法自行配置,那么最好就用2.7,而且主要区别在于反向代理方面,而我们用的是正向代理。

 

然后呢,去下载一个apache的windows版,把里面的htpasswd.exe拿出来,我是放在c:\service\squid\sbin里面。找不到的朋友可以点这里下载:

http://pan.baidu.com/s/1hslsWkO

接下来,我们来修改配置文件 c:\service\squid\etc\squid.conf ,建议将这个文件改名,直接自己新建一个,因为需要修改的项目非常多

我自己的配置文件内容:

#	WELCOME TO SQUID 2.7.STABLE8#

acl all src all

auth_param basic program c:/Service/squid/libexec/ncsa_auth.exe c:/Service/squid/etc/user.txt
auth_param basic children 5
auth_param basic realm Welcome to my proxy server


# 定义允许的端口
acl Safe_ports port 80 8080 443

# 拒绝所有不允许访问的端口,如果不想限制,可以屏蔽下面这一行

http_access deny !Safe_ports


# 定义授权组
acl squid_user proxy_auth REQUIRED
# 允许授权组
http_access allow squid_user


# 拒绝其它所有未定义的
http_access deny all

# Squid 端口,这里可以根据你需要修改

http_port 5555

hierarchy_stoplist cgi-bin ?

#因为是正向代理,所以不需要缓存,也最好不好缓存
cache_mem 0 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 20 MB
maximum_object_size_in_memory 8 MB
cache_dir ufs c:/Service/squid/cache 100000 4 6


ipcache_size 2048
fqdncache_size 2048

cache_vary on
reload_into_ims on

memory_replacement_policy heap LFUDA       
cache_replacement_policy heap GDSF



strip_query_terms off
cache_store_log none
pid_filename c:/Service/squid/squid.pid

mime_table c:/service/squid/etc/mime.conf
unlinkd_program c:/service/squid/libexec/unlinkd.exe
logfile_daemon c:/service/squid/libexec/logfile-daemon.exe
icon_directory c:/service/squid/share/icons

acl shoutcast rep_header X-HTTP09-First-Line ^ICY.[0-9]
upgrade_http0.9 deny shoutcast
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache

header_access X-Cache deny all
header_access X-Squid-Error deny all
header_access Via deny all
header_access Server deny all
header_access X-Cache-Lookup deny all
visible_hostname cdn1.tingtao.org
error_directory c:/Service/squid/share/errors/Simplify_Chinese
coredump_dir c:/Service/squid/cache
windows_ipaddrchangemonitor off

 

配置中有一些可有可无的设置,纯属我个人习惯,各位熟悉squid的话,根据自己需求可以调整,不熟的话拿着我的就可以直接用了。

然后来将squid安装为windows系统服务,打开命令行,复制以下内容:

mkdir C:\Service\squid\Cache
cd /d C:\Service\squid\sbin
squid.exe -z -f C:/Service/squid/etc/squid.conf
squid.exe -i -f C:/Service/squid/etc/squid.conf
net start squid

然后呢,你的http代理就架设好了,下面可以添加用户了,命令:

C:\Service\squid\sbin\htpasswd.exe -c C:\Service\squid\etc\user.txt 用户名

根据提示输入两次密码即可,第一次要加 -c 这个参数,后面添加其他的用户名就不用加了:

C:\Service\squid\sbin\htpasswd.exe C:\Service\squid\etc\user.txt 用户名2

 

至此,windows平台上基于squid的http代理就做好了,不过这是明文代理,也就是说如果你看了一些不太科学的东西,有可能被墙或者被封,所以建议参考《Windows Server上使用stunnel+ccproxy配置加密代理 》这篇文章用stunnel做成加密代理,这样就皆大欢喜了。

作者 听涛

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注