-
Notifications
You must be signed in to change notification settings - Fork 0
TCP proxy
matveynator edited this page Apr 29, 2023
·
6 revisions
#!/bin/bash
apt-get -y install socat net-tools &> /dev/null
echo "============================"
echo "Please enter destination ip:"
read DST_IP
[ "${DST_IP}" == "" ] && echo "empty ip!" && exit 1
echo "stopping nginx and apache..."
/etc/init.d/nginx stop
/etc/init.d/apache2 stop
echo "done."
echo "proxying with socat to ${DST_IP} ..."
socat TCP4-LISTEN:80,fork TCP4:${DST_IP}:80 &
socat TCP4-LISTEN:443,fork TCP4:${DST_IP}:443 &
echo "done"
netstat -lpan |grep 80 |grep socat
netstat -lpan |grep 443 |grep socat
socat TCP4-LISTEN:80,fork TCP4:${DST_IP}:80
socat TCP4-LISTEN:443,fork TCP4:${DST_IP}:443
apt-get install -y xinetd
cat >> /etc/xinetd.d/8888 <<EOF
service 8888
{
disable = no
type = UNLISTED
socket_type = stream
protocol = tcp
wait = no
redirect = 10.9.8.7 8888
bind = 0.0.0.0
port = 8888
user = nobody
}
systemctl reload xinetd