tinyproxy代理简单使用

官网地址说明

https://tinyproxy.github.io/

Tinyproxy是POSIX操作系统的轻量级HTTP / HTTPS代理守护进程。从一开始就设计为快速而小巧,它是用于需要全功能HTTP代理的嵌入式部署等用例的理想解决方案,但是较大代理的系统资源不可用。

Tinyproxy允许转发HTTPS连接,而无需通过该CONNECT方法以任何方式修改流量(请参阅ConnectPort指令)。

使用该AddHeader指令,您可以向传出流量添加/插入HTTP标头。

 

安装

[root@liyu ~]# yum install tinyproxy -y

 

启动、停止

[root@liyu ~]# service tinyproxy start

Redirecting to /bin/systemctl start tinyproxy.service

[root@liyu ~]# service tinyproxy status

[root@liyu ~]# service tinyproxy stop

 

配置

User tinyproxy
Group tinyproxy

Port 8889


Timeout 600


DefaultErrorFile "/usr/share/tinyproxy/default.html"


StatFile "/usr/share/tinyproxy/stats.html"

LogFile "/var/log/tinyproxy/tinyproxy.log"


LogLevel Info

PidFile "/var/run/tinyproxy/tinyproxy.pid"

MaxClients 100

MinSpareServers 5
MaxSpareServers 20

StartServers 10

MaxRequestsPerChild 0

ViaProxyName "tinyproxy"


ConnectPort 443
ConnectPort 563

连接测试

在另一台客户机上输入

curl -x : www.baidu.com

其中IP和PORT是代理服务器的IP和代理端口,如果出现百度的源代码,则证明代理配置成功。

提供启动脚本:

[root@test-01 ~]# cat /etc/init.d/tinyproxy

#!/bin/sh

#

# tinyproxy Startup script for the tinyproxy server

#

# chkconfig: - 85 15

# description: small, efficient HTTP/SSL proxy daemon

#

# processname: tinyproxy

# config: /etc/tinyproxy/tinyproxy.conf

# config: /etc/sysconfig/tinyproxy

# pidfile: /var/run/tinyproxy.pid

#

# Note: pidfile is created by tinyproxy in its config

# see PidFile in the configuration file.

 

# Source function library.

. /etc/rc.d/init.d/functions

 

# Source networking configuration.

. /etc/sysconfig/network

 

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

 

exec="/usr/sbin/tinyproxy"

prog=$(basename $exec)

config="/etc/tinyproxy/tinyproxy.conf"

 

[ -e /etc/sysconfig/tinyproxy ] && . /etc/sysconfig/tinyproxy

 

lockfile=/var/lock/subsys/tinyproxy

 

start() {

[ -x $exec ] || exit 5

[ -f $config ] || exit 6

echo -n $"Starting $prog: "

daemon $exec -c $config

retval=$?

echo

[ $retval -eq 0 ] && touch $lockfile

return $retval

}

 

stop() {

echo -n $"Stopping $prog: "

killproc $prog

retval=$?

echo

[ $retval -eq 0 ] && rm -f $lockfile

return $retval

}

 

restart() {

stop

start

}

 

reload() {

echo -n $"Reloading $prog: "

killproc $prog -HUP

echo

}

 

force_reload() {

restart

}

 

rh_status() {

status $prog

}

 

rh_status_q() {

rh_status >/dev/null 2>&1

}

 

case "$1" in

start)

rh_status_q && exit 0

$1

;;

stop)

rh_status_q || exit 0

$1

;;

restart)

$1

;;

reload)

rh_status_q || exit 7

$1

;;

force-reload)

force_reload

;;

status)

rh_status

;;

condrestart|try-restart)

rh_status_q || exit 0

restart

;;

*)

echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"

exit 2

esac

exit $?

 

 

 

你可能感兴趣的:(运维)