树莓派搭建代理服务器

平台:树莓派3B+

系统:Raspberry Pi OS 32位

Linux内核版本:5.10

日期:2021.5

1、安装squid软件。

sudo apt install squid

2、定位到/etc/squid/squid.conf,编辑squid的配置文件。

sudo nano squid.conf

3、默认是不允许外部连接,只需在首行添加允许连接。

http_access allow all

4、添加下列语句可以使用认证登录

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/squid_user.txt
acl auth_user proxy_auth REQUIRED
http_access allow auth_user

其中第一行的/etc/squid/squid_user.txt路径表示登录用户名和密码文件,会使用/usr/lib/squid/basic_ncsa_auth路径下的软件进行读取。后面两行的作用是开启用户认证。

5、使用apache软件命令创建用户名和密码,所以需要安装过apache。

sudo htpasswd -c /etc/squid/squid_user.txt yonghuming
New password:mima
Re-type new password:mima
Adding password for user yonghuming

6、重启squid服务

sudo service squid restart

7、在Windows的设置->网络和Internet->代理中,打开代理,填写服务器地址和端口,保存。

8、在浏览器中第一次使用代理服务器浏览时,会要求提供用户名和密码。

THE END