0

I have a SOCKS proxy that is accessible at 192.168.0.17:1080 in my local network. I redirected my internet traffic to it in my Wifi System Preferences. This works fine, GUI applications use it. However I'm not able to use the proxy inside the terminal through environment variables. Only setting it explicitly works.

In other words, this works

curl --socks5-hostname 192.168.0.17:1080 https://apple.stackexchange.com

But this doesn't work

# exports are also in ~/.zshrc
export HTTP_PROXY="socks5://192.168.0.17:1080"
export http_proxy="socks5://192.168.0.17:1080"
export HTTPS_PROXY="socks5://192.168.0.17:1080"
export https_proxy="socks5://192.168.0.17:1080"
export ALL_PROXY="socks5://192.168.0.17:1080"

curl https://apple.stackexchange.com

This is not just the case for curl but also other applications such as git.

2
  • 1
    Looks like you're not using the documented "socks5h://" from the man page, specified as the equivalent to --socks5-hostname. Any particular reason? Commented Oct 26, 2019 at 20:17
  • It works with "socks5h://", at least for some applications. You can write an answer if you'd like. What's the difference between h and non-h actually?
    – TomTom
    Commented Oct 27, 2019 at 7:56

1 Answer 1

2

If you're passing --sox5-hostname, then the equivalent in environment variables is "socks5h://", per the man page for curl(1):

PROXY PROTOCOL PREFIXES
       Since curl version 7.21.7, the proxy string may be specified with a  protocol://  prefix  to  specify
       alternative proxy protocols.

       If  no  protocol is specified in the proxy string or if the string doesn't match a supported one, the
       proxy will be treated as an HTTP proxy.

       The supported proxy protocol prefixes are as follows:

       socks4://
              Makes it the equivalent of --socks4

       socks4a://
              Makes it the equivalent of --socks4a

       socks5://
              Makes it the equivalent of --socks5

       socks5h://
              Makes it the equivalent of --socks5-hostname

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .