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.