Tuesday, February 14, 2017

http proxy in command line

$ export http_proxy="http://proxyserver:port"
$ export https_proxy="https://proxyserver:port"
$ export ftp_proxy="http://proxyserver:port"

If the proxy server requires login

$ export http_proxy="http://user:password@proxyserver:port"
$ export https_proxy="https://user:password@proxyserver:port"
$ export ftp_proxy="http://user:password@proxyserver:port"

If your password contains special characters, you must replace them with ASCII codes.

For example At symbol "@" should be replaced by "%40" (e.g. p@ssword = p%40ssword).

Testing Proxy

You can test the proxy by checking your public IP address from the command line :
$ wget -q -O - checkip.dyndns.org \
| sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

You may also use the time command to test the differences in the connection speed with proxy and without it :
$ time wget -q -O - checkip.dyndns.org \
| sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

Or you can easily test the Internet download speed with the following command :
$ wget --output-document=\
/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip

Unsetting Proxy Variable

Use the following commands to disable proxy :
$ unset http_proxy
$ unset https_proxy
$ unset ftp_proxy
Easy Proxy Usage

If you use the same proxy server for http, https and ftp traffic you can use the following commands to set and unset proxy :
$ export {http,https,ftp}_proxy="http://proxy-server:port"
$ unset {http,https,ftp}_proxy

If you have to use the proxy very often, you can create a bash shell function as follows (add to your ~/.bashrc) :

# Set Proxy
function setproxy() {
    export {http,https,ftp}_proxy="http://proxy-server:port"
}

# Unset Proxy
function unsetproxy() {
    unset {http,https,ftp}_proxy
}

http://proxylist.hidemyass.com/

export http_proxy="http://201.16.147.193:80"

No comments:

Blog Archive