Linux – special characters in http_proxy environment variable

bashcommand-line-interfacelinuxPROXY

What is the correct format using special characters in http_proxy environment variable?
Or to be mor specific, what to do with special characters in username or password when authenticate to http proxy on the command line.

Best Answer

At first, the complete format is:

http_proxy='http://user:pass@server:port/'

Every special character in username and password must not conflict with the characters used in the above format AND must be URL compliant.

Here is an example:

Domain: ADMIN DOM
User:   my@email.address  
PW:     a%b(c/x@y z
Server: proxy.server.at
Port:   8080

becomes:

'http://ADMIN%20DOM\my%40email.address:a%25b(c%2Fx%40y%20z@proxy.server.at:8080/'

And to prevent bash interpretation of any character always use single-quotes.

You can set this system wide in /etc/environment like this:

http_proxy='http://ADMIN%20DOM\my%40email.address:a%25b(c%2Fx%40y%20z@proxy.server.at:8080/'

Easy URL encoding/decoding:
https://duckduckgo.com/?q=url+encode+a%25b%28c%2Fx%40y+z&kl=at-de
or
https://duckduckgo.com/?q=url+escaping