squid正向代理

匿名代理

squid 要做到匿名代理 只需要添加

header_access Via deny all header_access  X-Forwarded-For deny all

即可

代理验证

谁都不想自己的代理服务器被他人随意拿来使用.. 于是 我们就需要给代理服务器加上密码

auth_param basic program /data/home/eleven/squid2.7/bin/ncsa_authauth_param basic children 1auth_param basic realm "Welcome to eleven's proxy server"auth_param basic credentialsttl 12 hours

这里的ncsa_auth 是自己写的shell脚本, 我的squid版本是2.7, 没有自带ncsa_auth程序

一个简单的代理验证脚本

while true;do    read line    username=`echo $line | awk '{print $1}'`;    password=`echo $line | awk '{print $2}'`;    if [ "x$username" == "xeleven" ]    then        if [ "x$password" == "x*****" ]        then            echo OK;        else            echo Err;        fi      else        echo Err;    fi  done

这个脚本有点类似之前的squid url跳转使用的脚本. 都是脚本从squid处接收需要处理的信息, 脚本处理完毕之后返回给squid结果

squid正向代理, 搭建 http 代理服务器

以下是一份完整的squid正向代理的配置文件

auth_param basic program /data/home/eleven/squid2.7/bin/ncsa_authauth_param basic children 1auth_param basic realm "Welcome to eleven's proxy server"auth_param basic credentialsttl 12 hoursacl all src all acl squid_user proxy_auth REQUIREDacl manager proto cache_objectacl localhost src 127.0.0.1/32acl SSL_ports port 443 acl Safe_ports port 80      # httpacl Safe_ports port 21      # ftpacl Safe_ports port 443     # httpsacl CONNECT method CONNECThttp_access allow manager localhosthttp_access deny managerhttp_access deny !Safe_portshttp_access deny CONNECT !SSL_portshttp_access allow localhost# 允许密码用户登录http_access allow squid_user# 拒绝其他所有请求http_access deny all# Squid的监听端口http_port **** # 不准暴力猜解我的密码. 哼# DNS 域名服务器配置dns_nameservers 8.8.8.8# 启动squid2.7的用户cache_effective_user elevencache_effective_group eleven# squid2.7访问日志; 调试时开启#cache_access_log /var/log/squid/access.log#cache_log /var/log/squid/cache.log# squid2.7挂掉后,core文件位置coredump_dir /data/home/eleven/squid2.7/# 高匿header_access Via deny allheader_access  X-Forwarded-For deny all# 出现cgi-bin或者?的URL不予缓存hierarchy_stoplist cgi-bin ? \.phpacl QUERY urlpath_regex -i cgi-bin [^html]\? \.asp \.php \.jsp \.cgiacl download urlpath_regex -i \.avi$ \.rmvb$ \.rm$ \.ra$ \.ram$ \.mpe$ \.smi$cache deny QUERYcache deny download# 磁盘缓存目录cache_dir ufs /data/home/eleven/squid2.7/cdir 500 16 256# 内存缓冲大小cache_mem 2M# 刷新缓存规则refresh_pattern ^ftp:       1440    20% 10080refresh_pattern -i (/cgi-bin/|\?) 0 0%  0refresh_pattern .       0   20% 4320

加密本地至squid的请求

前面的文章里面讲解过了使用Stunnel做加密解密, 本地使用socat做数据转发, 采用openssl 加密本地http数据,

参考文章

结束

至此, 一个全新的支持https访问的 http代理就搭建成功了. 第一次访问会要求你输入帐号和密码相信看过本人此前的文章 都知道我曾经使用了一个叫做kangle的工具 搭建了一个http代理.不知道从什么时候开始 kangle 搭建的代理 无法访问https协议的 站点. 于是,才迫使我转而使用squid.

squid正向代理

相关文章:

你感兴趣的文章:

标签云: