Tech/OS(Linux)

Socat Port forwarding and supervisord.service

눈꽃산행 2022. 9. 27. 11:59
Source ->  Proxy Svr
* Socat / 443
--> forwarding 8080
-->
sip proxy --> target
target
tcp 8443

 Centos 7.9

 

1. 설치

rpm -qa | grep socat
yum provides socat
yum install socat -y
curl ifconfig.me
ifconfig
socat

firwall-cmd --list-all
firewall-cmd --list-all
systemctl status sockets.target

---------------------------------------------------------

yum provides supervisord
yum install epel-release
yum -y install supervisor -y
systemctl status supervisord.service
systemctl start supervisord.service
systemctl status supervisord.service
cd /etc
ls -rlt
cd supervisord.d/
ls -rlt

 

2. socat config 설정

세션A ---> Locathost  443 포트  ---> 172.18.12.2:8443 포워딩

pwd
mkdir conf.d    # socat config  경로
cd conf.d/
vi socat_test.conf
[root@ahn_test conf.d]# cat socat_test.conf
[program:socat_ahntest_443]
command=/usr/bin/socat TCP-LISTEN:443,fork TCP:172.18.12.2:8443
directory=/logs
autostart=true
autorestart=true
startretries=3
stderr_logfile=/logs/ahntest_443_stderr.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=5
stdout_logfile=/logs/ahntest_443_stdout.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=5
[root@ahn_test conf.d]#

ls -rlt
cat socat_test.conf
--------------------------------------------------------------------------
vi supervisord.conf    # socat config 경로

[include]
files = supervisord.d/conf.d/*.conf


cat supervisord.conf

cd /var/log
ls -rlt
cd supervisor/
ls -rlt
tail supervisord.log
ps -ef | grep
ps -ef |
ps -ef
ps -ef | grep sup
ps -ef | grep supervisord.log
netstat -antp
cd /etc/supervisord.d/
ls -rlt
cd conf.d/
ls -rlt
cat socat_test.conf
netstat -antp | grep 443

systemctl restart supervisord.service
ls -rlt

pwd
mkdir logs        # 로그저장 경로
cd logs/
ls -rlt
systemctl start supervisord.service
ls -rlt
vi ahntest_443_stderr.log
ls -rlt
vi ahntest_443_stdout.log
ls -rlt
systemctl stop supervisord.service
systemctl restart supervisord.service
cd /etc/

 

systemctl status supervisord.service