侧边栏壁纸
博主头像
cn2linux博主等级

行动起来,活在当下

  • 累计撰写 128 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

草稿: Squid正向代理 (基于MySQL验证)

快速安装相关服务

yum install mariadb-server squid -y
yum install perl-DBD-mysql -y

创建配置数据库

启动服务并设置开机自启动:

sudo systemctl start mariadb
sudo systemctl enable mariadb

创建库为 squid_db:

create database squid_db charset = 'utf8';

创建账号表为 users:

CREATE TABLE `users`(
`id` INT(11) NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT 'id',
`account` VARCHAR(50) NOT NULL DEFAULT '' COMMENT "账号",
`password` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '密码',
`enabled` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '是否启用'
)engine=innodb charset='utf8';

创建数据库连接账号:

GRANT ALL ON squid_db.* TO 'admin'@'localhost' identified by 'admin';

配置SQUID服务

编辑 squid.cnf 文件:

vi /etc/squid/squid.conf

auth_param basic program /usr/lib64/squid/basic_db_auth --user admin --password admin --plaintext --persist
auth_param basic children 5
auth_param basic realm proxyserver
auth_param basic credentialsttl 20 hour
acl localnet proxy_auth REQUIRED src 0.0.0.0/0
http_access allow localnet
http_access deny all

编辑 basic_db_auth 文件:

vi /usr/lib64/squid/basic_db_auth

my $dsn = "DBI:mysql:database=squid_db;host=localhost";
my $db_user = "admin";
my $db_passwd = "admin";
my $db_table = "users";
my $db_usercol = "account";
my $db_passwdcol = "password";
my $db_cond = "enabled = 1";

启动squid并设置开机自启动:

systemctl start squid
systemctl enable squid

测试squid数据库连通性方式:

 /usr/lib64/squid/basic_db_auth --dsn "DBI:mysql:squid:xx.xx.xx.xx" --user proxyauth --password proxy2018 --plaintext --persist

<!--http://linchpincorner.blogspot.com/2016/08/squid-proxy-server-configuration-with_23.html -->

0

评论区