ubuntu http代理服务器

下载

1
sudo apt-get install squid

安装

sudo vim /etc/squid/squid.conf

1
2
3
4
5
6
7
8
9
10
11
#允许的客户端ip
acl allcomputers src 0.0.0.0/0.0.0.0
#配置用户名密码,后面会生成passwords文件
auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/passwords
auth_param basic realm proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated allcomputers

#http_access deny all

http_port 8128

用户密码验证

1
2
3
4
5
6
7
sudo apt-get install apache2-utils

sudo htpasswd -c -d /etc/squid/passwords 自定义用户名

sudo chmod o+r /etc/squid/passwords

sudo service squid start

验证

1
tail -f /var/log/squid/access.log

使用

1
2
export http_proxy="http://用户名:密码@代理IP:代理端口"
curl -l "http://www.baidu.com"
请作者喝一杯咖啡☕️