How To Use Wget using Proxy Server

Wget command using proxy

Wget is a free software package for retrieving files using HTTP, HTTPS, FTP and FTPS, the most widely used Internet protocols. It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without X-Windows support, etc.

Sometimes we need wget to use proxy, for example if you behind firewall or using proxy on your office or school.

There are many ways to use wget using proxy such as using wget command without change configuration, create / edit configuration in $HOME/.wgetrc (~/.wgetrc) or /etc/.wgetrc, and export proxy configuration globally for all application.

Using Wget Command without change configuration

# wget https://ifconfig.me -e use_proxy=yes -e http_proxy=127.0.0.1:8080

Example:

# wget https://ifconfig.me -e use_proxy=yes -e http_proxy=178.128.xxx.xxx:8080
Wget Command Using Proxy
Wget Command Using Proxy

Create / edit configuration in $HOME/.wgetrc (~/.wgetrc) or /etc/.wgetrc

If you create on ~/.wgetrc it’s only available on your profile and if edit on /etc/.wgetrc, ot’s will available globally. So it;s depend on your choices.

# vi ~/.wgetrc

Paste code below

http_proxy = http://[proxy_address]:[proxy_port]
https_proxy = http://[proxy_address]:[proxy_port]
ftp_proxy = http://[proxy_address]:[proxy_port]

Example:

http_proxy = http://178.128.xxx.xxx:8080
https_proxy = http://178.128.xxx.xxx:8080
ftp_proxy = http://178.128.xxx.xxx:8080

Export proxy configuratioinglobally for all application

This configuration is available for all application such as homebrew.

export http_proxy=[proxy_address]:[proxy_port]
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export dns_proxy=$http_proxy
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"

ServerDiary

ServerDiary

Leave a Reply

Your email address will not be published. Required fields are marked *