尝试在VPS 上装Squid 为我的Switch 做代理,这里只记录安装配置的方法。
1.安装
#sudo update #sudo apt-get install squid apache2-utils (需要htpasswd 来创建认证用户,在这个包里) |
2.配置
a.创建认证用户
#htpasswd -c /etc/squid/passwd your_username |
b.配置/etc/squid/squid.conf,系统默认配置如下
acl SSL_ports port 443 acl Safe_ports port 21 # ftp acl bafe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http-g acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localhost manager http_access deny manager http_access allow localhost http_access deny all http_port 3128 coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880 refresh_pattern . 0 20% 4320 |
http_port 3128 改为 http_port 3328(默认端口强烈建议更改,不然无数嗅探器天天来扫描 –#),注释掉http_access deny all 。
在文件最后增加
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd acl auth_user proxy_auth REQUIRED http_access allow auth_user http_access deny all |
#ufw allow 3328
(防火墙中开放代理端口)
备注
默认的配置文件里有很多注释和空行,可以在vim 执行 :g/^#/d
:g/^$/d
这两条命令分别删除注释行和空行。这样能让你的配置文件非常清爽。
网上有不少文章默认是 http_access allow all,千万不要加这条,加了这条你的代理就是个不设防的免费代理,就等着顾客盈门吧。