https正向代理 GoProxy

背景:

在安全隔离的内网环境中,部署于内网的应用如需调用公网第三方接口(如支付、短信),可通过正向代理服务实现访问。

GoProxy

下载:

https://github.com/snail007/goproxy/releases

使用文档:

GOPROXY 使用文档

支持

linux、windows、mac

darwin 是 mac 版的二进制版本

(执行文件可以改名)
hehemnt client -P 123.123.123.123:8005 -T tls -C proxy.crt -K proxy.key --k default

proxy client -P 123.123.123.123:8005 -T tls -C proxy.crt -K proxy.key --k default

可以写个启动脚本

#!/bin/bash
HOME=/data/soft/mnt
SERVER=123.123.123.123:8005

checkpid(){
    APP_PID=`ps -ef|grep $HOME|grep hehemnt|awk '{print $2}'`
}

#用于等待进程启停
wait_for_pid () 
{
  try=0
 case "$1" in
   'created')
  while test $try -lt 7 ; do
  printf .
  try=`expr $try + 1`
  sleep 1
  done   
  checkpid
  if [ "$APP_PID" != "" ] ; then
    try=''       
  fi
   ;;
   'removed')
  while test $try -lt 35 ; do  
  checkpid
  if [ "${APP_PID}" = "" ] ; then
    try=''
  break
  fi
  printf .
  try=`expr $try + 1`
  sleep 1
  done
   ;;
 esac
}

created_pid_status(){
  wait_for_pid created
  if [ -n "$try" ] ; then
    echo -e "\n\e[00;31mhehemnt start failed!\e[00m"
    exit 1
  else
    echo -e "\n\e[00;32mhehemnt startup!\e[00m"
  fi
}

start(){
  checkpid
  if [ ! -n "${APP_PID}" ]; then
    printf "Starting hehemnt"
    nohup hehemnt client -P $SERVER  -T tls -C proxy.crt -K proxy.key --k default> $HOME/client.log 2>&1 &
    created_pid_status
  else
      echo -e "\e[00;31mhehemnt is already running (pid: ${APP_PID})\e[00m"
  fi  
}

stop(){
    checkpid
    if [ ! -n "${APP_PID}" ]; then
     echo -e "\e[00;31mhehemnt not runing\e[00m"
    else
      kill -9 $APP_PID
      wait_for_pid removed
      if [ -n "$try" ] ; then
        echo -e "\e[00;31mhehemnt stop failed!\e[00m"
        exit 1
      else
        echo -e "\e[00;32mhehemnt stop!\e[00m"
      fi
    fi
}

status(){
   checkpid
   if [ ! -n "${APP_PID}" ]; then
     echo -e "\e[00;31mhehemnt not runing\e[00m"
   else
     echo -e "\e[00;31mhehemnt is already running (pid: ${APP_PID})\e[00m"
   fi
}

restart(){
    stop
    sleep 1s
    start
}


case $1 in
  start) start;;
  stop) stop;;
  restart) restart;;
  status) status;;
  *)  echo "USAGE: $0 [app-name] [start|stop|status|restart|log]";;
esac

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Arvin627

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值