CentOS6.5安装squid透明代理

    免流 泡泡 2947次浏览 已收录 0个评论

    1.安装yum源

    centos 5 32位

    rpm -ivh http://down.xuqunxiong.com/centos/yum/32-epel-release-5-4.noarch.rpm
    

    centos 5 64位

    rpm -ivh http://down.xuqunxiong.com/centos/yum/64-epel-release-5-4.noarch.rpm
    

    centos 6 32位

    rpm -ivh http://down.xuqunxiong.com/centos/yum/32-epel-release-6-8.noarch.rpm
    

    centos 6 64位

    rpm -ivh http://down.xuqunxiong.com/centos/yum/epel-release-5-4.noarch.rpm
    

    centos 7 64位

    rpm -ivh http://down.xuqunxiong.com/centos/yum/epel-release-latest-7.noarch.rpm
    

    2.安装squid

    yum install -y squid
    

    3.配置 /etc/squid.conf

    auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/squid_user
    auth_param basic children 5  
    auth_param basic realm Welcome to pycredit's proxy-only web server 
    acl SSL_ports port 443
    acl Safe_ports port 80
    acl Safe_ports port 21
    acl Safe_ports port 443
    acl Safe_ports port 70
    acl Safe_ports port 210
    acl Safe_ports port 1025-65535
    acl Safe_ports port 280
    acl Safe_ports port 488
    acl Safe_ports port 591
    acl Safe_ports port 777
    acl CONNECT method CONNECT
    acl squid_user proxy_auth REQUIRED
    via off
    request_header_access X-Forwarded-For deny all
    request_header_access user-agent  deny all
    reply_header_access X-Forwarded-For deny all
    reply_header_access user-agentdeny all
    http_port 8080
    http_access allow squid_user
    http_access deny all
    cache_dir ufs /var/spool/squid 100 16 256 read-only
    cache_mem 0 MB
    coredump_dir /var/spool/squid
    access_log /var/log/squid/squid_access.log
    visible_hostname TD-LTE/FDD-LTE
    

    http_port 8080是监听的端口,可以改成其它的

    执行权限

    chmod 0755 ./squid.conf
    

    4.加密代理端口
    新建加密文件 /etc/squid/jiami

    vi /etc/squid/jiami
    

    复制一下内容进去

    #!/usr/bin/expect
    set htpasswdpath [lindex $argv 0]
    set username [lindex $argv 1]
    set userpass [lindex $argv 2]
    # spawn the htpasswd command process
    spawn htpasswd -c $htpasswdpath $username
    # Automate the 'New password' Procedure
    expect "New password:"
    send "$userpass\r"
    expect "Re-type new password:"
    send "$userpass\r"
    expect eof
    
    cd /etc/squid/
    /etc/squid/jiami squid_user 用户名 密码
    

    把用户名和密码修改为自己的

    也可以用ncsa_auth生成账号和密码

    htpasswd -c /etc/squid/squid_passwd 用户名
    

    注意:输入密码的时候。在控制台是看不到的,然后输入两次相同密码回车即可,然后启动服务:service squid restart

    5.启动

    squid -z
    squid -s
    

    6.设置开机启动

    chkconfig squid on
    

    喜欢 (0)
    发表我的评论
    取消评论
    表情 贴图 加粗 删除线 居中 斜体 签到

    Hi,您需要填写昵称和邮箱!

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址