zoukankan      html  css  js  c++  java
  • 使用tinyproxy搭建http代理

    一、前言

     

    二、搭建环境

    * Linux laptop 2.6.32-45-generic #100-Ubuntu SMP Wed Nov 14 10:41:11 UTC 2012 i686 GNU/Linux

    * tinyproxy 1.8.1 

    三、安装方法

    $sudo apt-get install tinyproxy
    安装后自动以root权限开启了tinyproxy服务,且默认监听端口是8888

    四、启动帮助

    $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.

    五、根用户的启动方法

    * 默认启动
    $sudo service tinyproxy start

    * 重启
    $sudo service tinyproxy restart

    * 停止
    $sudo service tinyproxy stop

    六、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一行注释掉。

    4.3 Diy配置说明

    tinyproxy可以以普通用户权限运行,只要监听端口是公开的就可以了。具体Diy配置方法如下:
    -- 打包可执行程序与默认配置文件 --
    1. $which tinyproxy
    /usr/sbin/tinyproxy
    2. $cp /usr/sbin/tinyproxy ~/bin
    3. $cp /etc/tinyproxy.conf ~/etc

    -- 修改配置 --
    1. 将Port默认的8888改成你想要的端口(如ljysrv上面的8990 TCP端口)
    2. 将Allow 127.0.0.1注释掉
    3. 将Logfile改为/tmp/tinyproxy.log
    4. 将PidFile改为/tmp/tinyproxy.pid

    -- 启动 --
    1. $cd ~/bin
    2. $./tinyproxy -c ~/etc/tinyproxy.conf

    -- 关闭 --
    1. $killall tinyproxy

    配置 Tinyproxy

    Tinyproxy 的配置文件默认位于 /etc/tinyproxy.conf。在此,你 可以配置其使用的端口号(默认是 8888)、超时、允许的最大客户 端等等。如果你希望在任意位置都能访问代理服务器,那么可以将 默认的 Allow 行注释掉。

    注意更新配置后,需要 reload 服务才会生效。另外,如果开了 iptables 防火墙的话,需要添加如下规则:

    iptables -I INPUT -p tcp --dport 8888 -j ACCEPT

  • 相关阅读:
    iOS cannot find folder xcdatamodeld Xcode 7
    ios swift generator 文章推荐
    ios swift 2 新的OptionSetType使用方法
    Maven 教程(11)— Maven远程仓库的各种配置
    Maven 教程(10)— Maven依赖详解
    Maven 教程(9)— Maven坐标详解
    Maven设置MAVEN_OPTS环境变量
    Maven 教程(7)— Maven使用的最佳实践
    Maven 教程(6)— Maven之pom.xml文件简单说明
    Maven 教程(5)— Maven目录结构及常用命令说明
  • 原文地址:https://www.cnblogs.com/feiling/p/3940444.html
Copyright © 2011-2022 走看看