====== Squid proxy ====== [[https://www.notion.so/maiernte/Proxy-517d1dc751dd4eeea8ca98eb812907a0?pvs=4|Notion 上的笔记]] [[https://www.digitalocean.com/community/tutorials/how-to-set-up-squid-proxy-on-ubuntu-20-04|教学文章]] ===== 安装启动 ===== 安装命令 sudo apt update sudo apt install squid 启动/关闭服务 sudo systemctl start squid sudo systemctl enable squid sudo systemctl stop squid # 查看服务情况 sudo systemctl status squid ===== 查询 ===== ''%%squid -k parse%%'' 查看所有的配置情况 查看端口 ss -tuln | grep squid netstat -tuln | grep squid 如果不行的话, # 查看是否在运行 ps -ef | grep squid # 查看所有的端口 sudo netstat -tuln ===== 开通/关闭服务 ===== 外网 HTTP # http_access deny all http_access allow all 端口: 我的服务器开通了3129端口 http_port 3128 开通 socks 代理服务 http_port 3128 http_port 1080 socks ===== 用户认证 ===== 建立密码文档 sudo apt install apache2-utils sudo htpasswd -c /etc/squid/passwords 修改config文件 # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # include /etc/squid/conf.d/* auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/passwords auth_param basic realm proxy acl authenticated proxy_auth REQUIRED # Example rule allowing access from your local networks. acl localnet src your_ip_address # Adapt localnet in the ACL section to list your (internal) IP networks # from where browsing should be allowed #http_access allow localnet http_access allow localhost http_access allow authenticated # And finally deny all other access to this proxy http_access deny all ===== 测试服务 ===== 测试方式 * curl 命令 ''%%curl -v -x http://217.160.61.19:3129 https://google.com%%'' * nc -v ''%%nc -v 217.160.61.19 3129%%'' (仅仅测试端口是否开通,如果要看内容,使用上一条测试命令) * telnet * ++ 当前服务 | http://tonny:T0dayfine1@217.160.61.19:3129 ++ 查看 ''serverv2ray::/etc/squid'' 第二种方式 ''%%curl -x 217.160.61.19:3129 -U "username:passwd" ipinfo.io%%''