Pages

Saturday 28 March 2015

Configuring .wgetrc file for Wget Proxy: running Wget behind your Proxy server

Like most of the applications wget has a configuration file too – i.e. “wgetrc”. You can locate the file in  /etc/wgetrc folder. Configuring the proxy is only applicable for local settings (i.e. user specific) only. Please follow the steps provided bellow to apply the proxy settings. Perform these in Super User mode (i.e. “sudo su” in ubuntu).
Open the file ~/.wgetrc file. If the file doesn't exist, then create it.
 
cd   /etc/wgetrc
vim  .wgetrc

Now, add the following statement in the file  
http_proxy=http://SERVER_NAME:PORT_NUMBER

If your proxy requires authentication (i.e. Username & Password),  you have two methods to mention the username and password for proxy server. They are as follows:

Explicitly specify those arguments in the command directly
The arguments for username and password are “--proxy-user” and “--proxy-password”  respectively. The format for using them in the command line are:.
$ wget --proxy-user=USERNAME --proxy-password=PASSWORD FILE_NAME

Setting the values permanently in the “.wgetrc” configuration file
If your authentication information is static/fixed, then it’s always advised to change the configuration file (i.e. .wgetrc file) itself. To apply these changes, follow the steps listed below:

Open the .wgetrc file and append/add the following lines in it.
proxy_user=USERNAME
proxy_password=PASSWORD

Note: You can apply the ftp proxy along with the authentication credentials using the aforesaid method.

Once the proxy settings are successfully configured in the wgetrc file, each time you run wget, it will automatically connect to the proxy server. Sometimes for local/LAN based downloads, you may not need the proxy server. If you require to turn off the proxy settings, then use the “--no-proxy” argument in the command for getting the file. Refer following statement:

$ wget --no-proxy FILE_URL

More Wget Commands can be found here.

WGET Tips and Tricks Video for Curious Minds (Thank you GEEKBLOG.TV.. :) )