http代理设置  Linux

作者: Joncc | 来源:发表于2017-12-05 22:16 被阅读244次

    • ps:本教程适合linux

    安装 Tinyproxy
    在 Debian 中,通过执行以下指令可以安装 Tinyproxy:
    apt-get install tinyproxy
    配置 Tinyproxy
    Tinyproxy 的配置文件默认位于 /etc/tinyproxy.conf。在此,你 可以配置其使用的端口号(默认是 8888)、超时、允许的最大客户 端等等。如果你希望在任意位置都能访问代理服务器,那么可以将 默认的 Allow 行注释掉。
    注意更新配置后,需要 reload 服务才会生效。另外,如果开了 iptables 防火墙的话,需要添加如下规则:
    iptables -I INPUT -p tcp –dport 8888 -j ACCEPT


    一. �centos 下安装tinyproxy的教程,

    1. �安装tinyproxy

    • rpm安装
    rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
    
    • yum安装
      yum install tinyproxy -y
    

    下面黄色字体的不要配置

    Allow 127.0.0.1 //将127.0.0.1改成你自己的IP
      //例如你的IP 是1.2.3.4,你改成Allow 1.2.3.4,那只有你才可以连上这个Proxy
      //若你想任何IP都可以脸到Proxy在Allow前面打#注释
      service tinyproxy start

    2. Diy配置说明

    • tinyproxy可以以普通用户权限运行,只要监听端口是公开的就可以了。具体Diy配置方法如下:
    2.1打包可执行程序与默认配置文件
    1. 查看tinyproxy 位置 默认在/usr/sbin/tinyproxy
    $which tinyproxy 
    

    2.root目录下创建mkdir bin ; mkdir etc ;

    $cp /usr/sbin/tinyproxy ~/bin   
    
    1. 修改配置
    $cp /etc/tinyproxy.conf ~/etc
    
    2.2设置配置文件
    1. 将Port默认的8888改成你想要的端口(如ljysrv上面的8990 TCP端口)
    2. 将Allow 127.0.0.1注释掉
    3. 将Logfile改为/tmp/tinyproxy.log
    4. 将PidFile改为/tmp/tinyproxy.pid
    2.3启动
    • 记得在防火墙中开启8888端口号 出和入都要设置 阿里云在安全组中设置
    • iptables -L 查看防火墙规则
    1. $cd ~/bin
    2. $./tinyproxy -c ~/etc/tinyproxy.conf
    
    • 启动软件之后,查看一下8888端口有没有被监听
    netstat -ntl
    

    查看一下自己的代理端口是否开放,我这开放的8888端口,

    2.4 关闭
    1. $killall tinyproxy
    

    二. 命令和配置

    1、启动帮助

         $tinyproxy --help
      Usage: tinyproxy [options]
      Options are:
      -d Do not daemonize (run in foreground).
      -c FILE Use an alternate configuration file.
      -h Display this usage information.
      -l Display the license.
      -v Display version information.
    

    2、根用户的启动方法

      * 默认启动
      $sudo service tinyproxy start
      * 重启
      $sudo service tinyproxy restart
      * 停止
      $sudo service tinyproxy stop
    

    4、DIY配置

      4.1 默认配置文件位置
      /etc/tinyproxy.conf
      (可以从/etc/init.d/tinyproxy包装器脚本中查到)
      4.2 默认配置说明
      * 以根用户启动时,在初始化完成后切换uid/gid为nobody/nogroup
      * Port 默认监听端口为8888(该端口无需用root权限绑定)
      * 默认在所在网卡上监听
      * Logfile (必须)日志文件, 默认/usr/var/log/tinyproxy/tinyproxy.log,在LogFile文件不存在时会警告,不会运行失败。
      * Pidfile (必须)pid文件, 默认/usr/var/run/tinyproxy/tinyproxy.pid,在PidFile文件不存在时会运行失败。
      * StartServers 初始启动的代理服务器子进程(默认是10个)
      *** Allow 允许使用tinyproxy进行HTTP代理的IP地址。默认是127.0.0.1,如果想要公开tinyproxy代理服务器,则把Allow一行注释掉。
    

    相关文章

      网友评论

        本文标题:http代理设置  Linux

        本文链接:https://www.haomeiwen.com/subject/qawfixtx.html