squid代理配置

1. 概述

本篇记录如何使用squid做代理,修改默认端口,允许特定网段节点使用代理访问特定域名

2. 过程

2.1 生成账号密码文件

htpasswd -c /etc/squid/.squid_users liwl
输入密码:liwanliang
执行结束,会创建/etc/squid/.squid_users
#账号liwl,密码:liwanliang

修改权限:chown squid.squid /etc/squid/.squid_users

验证:/usr/lib64/squid/basic_ncsa_auth /etc/squid/.squid_users

2.2 编辑配置文件

dns_v4_first on
acl SSL_ports port 443
acl CONNECT method CONNECT
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/.squid_users
auth_param basic children 5
auth_param basic realm Proxy Authentication Required
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl auth_users proxy_auth REQUIRED
acl user_liwl proxy_auth liwl
acl allowDomain dstdomain .qyapi.weixin.qq.com
http_access allow allowDomain
http_access deny !allowDomain
http_access allow localnet user_liwl
http_access deny all
http_port xxxx
coredump_dir /var/spool/squid
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

保存配置,重启服务:systemctl restart squid

2.3 测试

curl -x 172.19.1.2:xxxx -U liwl:liwanliang --proxy-basic -o liwl.AppImage https://get.wiz.cn/x/wiznote-desktop-0.1.103-linux-x86_64.AppImage

posted @ 2024-02-01 09:23  liwldev  阅读(15)  评论(0编辑  收藏  举报