Redirect port on Linux by socat
2018_01_27
Recently when I run gradlew run, I found the files gradlew wanted
to fetch on a server were blocked by Verification Code, I could
enter the verification code manually from Chrome and download the
files but gradlew can’t.
So, I need to set up a local server to redirect the server to my
localhost.
Since I have a Apache server listening port 1994, I need to
redirect port 80 to port 1994 and download the needed file
to /srv/www/htdocs/ and mkdir the corresponding subdirs.
After that, sudo vi /etc/hosts and add
127.0.0.1 www.loc.gov
Then, use socat
sudo socat TCP-LISTEN:80,fork TCP:127.0.0.1:1994
Finally, rerun gradlew run and everything went smoothly.
本文介绍了一种使用socat工具进行端口转发的方法,解决了gradlew运行时因验证码阻挡而无法获取文件的问题。作者通过将外部端口80转发到本地服务器的1994端口,实现了文件的顺利下载。
1595

被折叠的 条评论
为什么被折叠?



