Linux下使用Squid架设代理服务器

Published: Tags: SHELL PROXY

现在,我们先来配置好代理服务器,让其能正常工作: 1、安装Squid,这个不详细讲,apt-get install squi就能安装上。 2、终端命令,sudo gedit /etc/squid/squid.conf 3、把http_access deny all改为http_access allow all 4、终端命令,sudo squid -z,再sudo squid就把代理服务器架设好了。

好了,上面的代理服务器弄好之后,再来看看需要代理的电脑如何设置: 5、Win的:IE -> 选项 -> 连接 -> 局域网设置 -> IP:代理服务器地址 -> 端口:默认是3128 6、Linux的:System -> Preferences -> Network Proxy -> IP:代理服务器地址 -> 端口:默认是3128

至于怎么样可以限制允许指定IP登陆,看下文: 1、终端命令:sudo gedit /etc/squid/squid.conf 2、http_access deny all这一句不要改,保持deny all让不相关的电脑无法使用代理。 3、用gedit搜索\nacl all,会转到一个类似下方代码的地方:

#Recommended minimum configuration:
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32

4、在acl to_localhost dst 127.0.0.0/8 0.0.0.0/32下方添加: (指定某一IP和C类IP可使用此代理,下面的icyomik和c_ip是我使用的可登陆帐号,你可以自己修改)

#Recommended minimum configuration:
acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32
acl icyomik src 192.168.167.167/32 #改成你自己的
acl c_ip src 192.168.168.0/255.255.255.0 #改成你自己的

5、用gedit搜索\nhttp_access allow localhost,会转到一个类似下方代码的地方:

#http_access allow localnet
http_access allow localhost
# And finally deny all other access to this proxy
http_access deny all

6、在http_access allow localhost下方,http_access deny all上方添加代码,如下:

#http_access allow localnet
http_access allow localhost
http_access allow icyomik #改成你自己的
http_access allow c_ip #改成你自己的
# And finally deny all other access to this proxy
http_access deny all

7、终端命令,sudo squid -k reconfigure就把代理服务器架设好了,若无法正常工作,请检查防火墙设置。

完成好我所需要的设置了,至于如何使用帐号密码登陆代理服务器,请Google之,下面是对Squid的设置的补充,可以自行修改: http_port 808 //默认端口为3128 cache_mem 32 MB //高速缓存大小,默认8MB cache_dir ufs /var/spool/squid 100 16 256 //100表示缓存大小,单位MB;16个一级目录,256个二级目录