Centos使用squid搭建验证代理服务器
为了使奥维地图能够跑上谷歌卫星图,今日尝试了多种代理方式,分别由Apache模式、tinyproxy模式,但都无法实现有验证模式,使得代理极不安全。于是又找到了centos上另一代理方式——squid。其搭建过程如下:
1、centos安装squid
yum install -y squid
2、启动服务并设置成开机启动
systemctl start squid.service
systemctl enable squid.service
3、配置受信
①、为了让受信的服务器连接,需要对squid
配置账号验证授权使用,这里可通过apache的 htpasswd生成密码文件,首先查看是否安装:
yum list | grep httpd
②、如果没安装,就用如下命令安装Apache(在Linux系统中,Apache其实叫“httpd”):
yum install httpd
③、创建用户,设置密码:
htpasswd -cd /etc/squid/passwords username
上面的passwords是保存用户、密码的文件名,可自定义,username是自己设定的用户名,后面就会分别两次提示输入密码(比如123456),当然输入的时候是看不到任何字符的。注意,密码位数不能超过8位,我之前没注意到,试了好久才在网上找到答案。为了顺利进行后面的步骤,建议验证下用户名和密码:
/usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
回车后输入用户名和密码:
username 123456
回车会提示OK,否则说明用户名密码没设置成功。
4、配置squid.conf
文件地址:/etc/squid/
我习惯用WinSCP软件修改,习惯VIM的输入命令:
vim /etc/squid/squid.conf
①、Centos7.0以上用户在该文件最后加入以下内容:
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords auth_param basic children 30 auth_param basic credentialsttl 5 hours acl ncsa_users proxy_auth REQUIRED http_access allow ncsa_users
Centos6.5用户如下:
auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/passwords auth_param basic children 30 auth_param basic credentialsttl 5 hours acl ncsa_users proxy_auth REQUIRED http_access allow ncsa_users
②、注释掉以下内容,即在语句内容前加#
# http_access allow localnet # http_access allow all
5、重启squid生效
service squid restart
6、在奥维地图配置http代理:
系统--系统设置--高级,找到“HTTP代理 ”,选择自定义,点击后面的省略号按钮,选择“全部代理(除企业服务器)”,在下面依次输入代理服务器的IP地址或域名,认证类型选择“认证”,输入刚才设置的用户名和密码,点击“确定”完成。
这样就可以访问自定义地图中的谷歌卫星混合图了。