I want to route all outgoing connections to the internet from a Phoenix application via a socks5 proxy.
How to do that?
UPDATE
For example, it seems that the Langchain
library is using Req
. Other libraries might use Httpoison
or Finch
. Is there a way to configure a socks5 proxy for a Phoenix application at the very base level ? Meaning that any HTTP request done by any library would be routed via the socks5 proxy?
1 Like
I have found a solution:
Using proxychains4
with proxy_dns
commented out in /etc/proxychains4.conf
.
NOTE:
Documentation says:
proxychains4 supports TCP only (no UDP/ICMP etc). Not sure how this can affect the functionality of Phoenix applications.
For now it is doing the job, any HTTP request originating from the Phoenix application to the Internet uses now the specified SOCKS5 proxy, independent of the HTTP client used in Phoenix.
Your thoughts and comments are more than welcome 
UPDATE
For better performance, still proxychains4 can be used but instead of socks on remote server, tunnel via SSH to remote server.