服务器端设置
1.安装squid
#ubuntu安装方法:
sudo apt-get install squid
#centos安装方法:
yum install squid
2.修改配置
sudo vi /etc/squid/squid.conf
3.定位到http_access allow
#http_access allow localnet
http_access allow localhost
http_access allow lan #授权lan组,可以自己命名
# And finally deny all other access to this proxy
http_access deny all
4.定位到acl CONNECT method CONNECT,添加
acl lan src 192.168.0.10 10.10.0.0/24 #设置你允许访问的ip,也可以设置网段
5.再搜索http_port 3128,修改端口号,也可以不修改
# Squid normally listens to port 3128
http_port 3128
6.重启squid,使配置生效
#ubuntu
sudo service squid restart
#centos6
service squid restart
chkconfig squid on
#centos7
systemctl start squid
systemctl enable squid
客户端设置:
#windows系统ie浏览器中设置http代理
#centos系统全局的代理设置:
vi /etc/profile
#添加下面内容
export http_proxy=http://proxy_ip:port/
export ftp_proxy=http://proxy_ip:port/
export https_proxy=http://proxy_ip:port/
#如果需要用户名密码就这样设置
export http_proxy=http://username:password@proxy_ip:port/
#ubuntu系统全局的代理设置:
sudo gedit /etc/apt/apt.conf
#在文件中加入下面内容
Acquire::http::Proxy "http://proxy_ip:port";
Acquire::ftp::Proxy "http://proxy_ip:port";
Acquire::https::Proxy "http://proxy_ip:port";