配置基礎認證而且限制用戶必須使用認證。vim
[root@server ~]# yum -y install httpd-tools服務器
[root@server ~]# vi /etc/squid/squid.confide
acl CONNECT method CONNECTui
# line 26: 添加如下行來開啓認證雲計算
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/.htpasswdspa
auth_param basic children 5代理
auth_param basic realm Squid Basic Authenticationrest
auth_param basic credentialsttl 5 hoursorm
acl password proxy_auth REQUIREDserver
http_access allow password
# 添加一個用戶
[root@server ~]# htpasswd -c /etc/squid/.htpasswd jeffrey
[root@server ~]# systemctl restart squid
[root@client ~]# vi /etc/profile
# add follows to the end
# username:password@proxyserver:port
MY_PROXY_URL="http://jeffrey:redhat@server.example.com:8080/"
HTTP_PROXY=$MY_PROXY_URL
HTTPS_PROXY=$MY_PROXY_URL
FTP_PROXY=$MY_PROXY_URL
http_proxy=$MY_PROXY_URL
https_proxy=$MY_PROXY_URL
ftp_proxy=$MY_PROXY_URL
export HTTP_PROXY HTTPS_PROXY FTP_PROXY http_proxy https_proxy ftp_proxy
[root@client ~]# source /etc/profile
# 針對YUM
[root@client ~]# vim /etc/yum.conf
# 在後面添加
proxy=http://server.example.com:8080/
proxy_username=jeffrey
proxy_password=redhat
# 針對wget
[root@client ~]# vi /etc/wgetrc
# 在後面添加
http_proxy = http://server.example.com:8080/
https_proxy = http://server.example.com:8080/
ftp_proxy = http://server.example.com:8080/
proxy_user = jeffrey
proxy_passwd = redhat