desproxy的功能就是一级代理+端口映射
对本地指定的一个端口的请求会经过代理送到远程的主机
远程主机是代理服务器的话就实现了二级代理的功能:)
对本地指定的一个端口的请求会经过代理送到远程的主机
远程主机是代理服务器的话就实现了二级代理的功能:)
- 怎样获得Desproxy?
http://desproxy.sourceforge.net/
页面最下面右下角,有一个project page的链接
真正的下载页面是
http://sourceforge.net/project/showfiles.php?group_id=30464&release_id=90041
现在有三个平台的支持,windows,linux和macos,我们就用linux吧 - 安装
下载后获得一个desproxy-0.1.0-pre1.tgz文件(很快的,只有55k)
推荐使用root安装,不会碰到什么麻烦
解压:
$tar zxvf desproxy-0.1.0-pre1.tgz
$./configure
$make
$make install
checking for C compiler default output... configure: error: C compiler cannot create executables
可能是库的问题,通过如下方法解决:
sudo apt-get install libc6-dev
- desproxy的一般用法是
$desproxy remote_host remote_port proxy_host proxy_port local_port
使用全局变量来设置:
export PROXY_USER=username:password
Establishing proxy...
-----------------------------------
desproxy 0.1.0-pre3
(C) 2003 Miguelanxo Otero Salgueiro
-----------------------------------
TCP port 8080 Bound & Listening
Press <Control+C> to Quit
Connection request from 127.0.0.1, port 1135
Connecting to http proxy (xxx.xxx.xxx.xxx:8080)
Connection #0: bidirectional connection stablished
Connection #0: client -> proxy 522 bytes read
Connection #0: proxy -> client 1448 bytes read
Connection request from 127.0.0.1, port 1137
Connecting to http proxy (xxx.xxx.xxx.xxx:8080)
Connection #1: bidirectional connection stablished -
启动脚本和配置文件
----------------/etc/init.d/desproxy------------------------
#!/bin/bash
if [ ! -x /usr/local/bin/desproxy ]; then
echo "Missing desproxy exec file! May not installed properly."
exit 0
fi
if [ ! -f /etc/desproxy.conf ]; then
echo "Missing configuration file!"
exit 0
fi
. /etc/desproxy.conf
start_desproxy() {
if [ -n "$(ps -eo "%a" | grep /usr/local/bin/desproxy
| grep -v grep)" ];
then
echo "Desproxy has already run!"
exit 0
fi
env PROXY_USER=$PROXY_USER /usr/local/bin/desproxy $REMOTE_SERVER
$REMOTE_PORT $PROXY_SERVER $PROXY_PORT $LOCAL_PORT
1>/var/log/desproxy.log 2>&1 &
echo "Desproxy is running now!"
}
stop_desproxy() {
DESPROXYPID=$(ps -eo "%p %a" | grep /usr/local/bin/desproxy
| grep -v grep)
kill -15 $DESPROXYPID 1>/dev/null 2>&1
echo "Desproxy is terminated!"
}
case "$1" in
start)
start_desproxy
;;
stop)
stop_desproxy
;;
restart)
stop_desproxy
start_desproxy
;;
*)
echo "Usage: /etc/init.d/desproxy {start|stop|restart}"
exit 1
esac
exit 0
----------------------------/etc/desproxy.conf-----------------------
PROXY_USER=xxxxxx:xxxxxxxxx
REMOTE_SERVER=xxx.xxx.xxx.xxx
REMOTE_PORT=xxxx
PROXY_SERVER=xxxx.xxx.xxx.xxx
PROXY_PORT=xxxx
LOCAL_PORT=xxxx