How can I set a proxy for Wget?
Asked Answered
S

12

312

I want to download something with Wget using a proxy:

HTTP Proxy: 127.0.0.1
Port: 8080

The proxy does not need a username and password.

How can I do this?

Saluki answered 26/6, 2012 at 16:21 Comment(0)
N
552

For all users of the system via the /etc/wgetrc or for the user only with the ~/.wgetrc file:

use_proxy=yes
http_proxy=127.0.0.1:8080
https_proxy=127.0.0.1:8080

or via -e options placed after the URL:

wget ... -e use_proxy=yes -e http_proxy=127.0.0.1:8080 ...
Needlework answered 26/6, 2012 at 16:27 Comment(6)
My wget says it must be use_proxy=on, not use_proxy=yes. Works well otherwise.Yvetteyvon
Checked. It works with wget -e <http_proxy>=127.0.0.01:8080 <download>..., omitting the "use_proxy=yes" command parameter. Thanks!Mayweed
@Thomas Jensen You are right the wgetrc-manual states that it should be on or off, but actually trying a bogus command: -e use_proxy=bnw gives wget: use_proxy: Invalid boolean ‘bnw’; use 'on' or 'off'. while =yes gives no such error, so it seems to be inofficially allowed.Beaconsfield
http_proxy=http://<user>:<password>@127.0.01:8080 and likewise. otherwise you might have to feed these explicitly while calling the wget (refer - askubuntu.com/a/429943/350255)Pivot
How do I turn it off?Blandishment
@Tessaracter : wget --no-proxyHexad
M
105

Type on the command line:

export http_proxy=http://proxy_host:proxy_port

For an authenticated proxy,

export http_proxy=http://username:password@proxy_host:proxy_port

And then run

wget fileurl

For https, just use https_proxy instead of http_proxy. You could also put these lines in your ~/.bashrc file, so that you don't need to execute this every time.

Moderato answered 10/9, 2013 at 14:55 Comment(3)
How to remove the proxyBlandishment
$ unset http_proxyModerato
experimentally found that needed to use lower case, not upper case $ wget --version GNU Wget 1.14 built on linux-gnu. +digest +https +ipv6 +iri +large-file +nls +ntlm +opie +ssl/opensslRatsbane
S
46

The following possible configurations are located in /etc/wgetrc. Just uncomment and use it...

# You can set the default proxies for Wget to use for http, https, and ftp.
# They will override the value in the environment.
#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/

# If you do not want to use proxy at all, set this to off.
#use_proxy = on
Sake answered 26/6, 2012 at 16:26 Comment(0)
A
22

Wget uses environment variables. Something like this at the command line can work:

export http_proxy=http://your_ip_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"
Aphra answered 1/11, 2013 at 2:24 Comment(0)
M
19

After trying many tutorials to configure my Ubuntu 16.04 LTS (Xenial Xerus) system behind an authenticated proxy, it worked with these steps:

Edit /etc/wgetrc:

sudo nano /etc/wgetrc

Uncomment these lines:

#https_proxy = http://proxy.yoyodyne.com:18023/
#http_proxy = http://proxy.yoyodyne.com:18023/
#ftp_proxy = http://proxy.yoyodyne.com:18023/
#use_proxy = on

Change http://proxy.yoyodyne.com:18023/ to http://username:password@domain:port/

Important: If it still doesn't work, check if your password has special characters, such as #, @, ... If this is the case, escape them (for example, replace passw@rd with passw%40rd).

Mestas answered 4/1, 2017 at 14:41 Comment(0)
R
13

If you need to execute wget just once with the proxy, the easiest way is to do it with a one-liner like this:

http_proxy=http://username:password@proxy_host:proxy_port wget http://fileurl

or with an https target URL:

https_proxy=http://username:password@proxy_host:proxy_port wget https://fileurl
Rehearse answered 8/4, 2019 at 13:39 Comment(0)
U
6

In Debian Linux, wget can be configured to use a proxy both via environment variables and via wgetrc. In both cases, the variable names to be used for HTTP and HTTPS connections are

http_proxy=hostname_or_IP:portNumber
https_proxy=hostname_or_IP:portNumber

Note that the file /etc/wgetrc takes precedence over the environment variables, hence if your system has a proxy configured there and you try to use the environment variables, they would not seem to have any effect!

Urogenital answered 18/4, 2016 at 16:2 Comment(0)
R
6

Use

export http_proxy=http://proxy_host:proxy_port/
export https_proxy=https://proxy_host:proxy_port/

or

export http_proxy=http://username:password@proxy_host:proxy_port/
export https_proxy=https://username:password@proxy_host:proxy_port/

As all others explained here, these environment variables help to pass on proxies.

Note: But please note that if the password contains any special character then that needs to be configured as %<hex_value_of_special_char>.

Example: If the password is pass#123, it needs to be used as pass%23123 in the above export commands.

Ramiform answered 21/2, 2019 at 14:16 Comment(0)
M
5

In my Ubuntu installation, the following lines in $HOME/.wgetrc did the trick!

http_proxy = http://uname:[email protected]:8080

use_proxy = on

Microclimatology answered 1/9, 2014 at 8:54 Comment(0)
L
5

Add below line(s) in file ~/.wgetrc or /etc/wgetrc (create the file if it is not there):

http_proxy = http://[Proxy_Server]:[port]
https_proxy = http://[Proxy_Server]:[port]
ftp_proxy = http://[Proxy_Server]:[port]

For more information, https://www.thegeekdiary.com/how-to-use-wget-to-download-file-via-proxy/

Ligni answered 11/9, 2019 at 8:26 Comment(0)
B
5

Start Wget through a SOCKS5 proxy using tsocks:

  1. install tsocks: sudo apt install tsocks

  2. configure tsocks

    As root:

    vi /etc/tsocks.conf
    

    Add:

    server = 127.0.0.1
    server_type = 5
    server_port = 1080
    
  3. start: tsocks wget http://url_to_get

Bukharin answered 7/5, 2020 at 7:48 Comment(2)
SOCKS server is not on a local subnet! failed: Connection refused.Hoebart
wget: unable to resolve host address ‘google.com’Kassiekassity
C
2

In Windows - for Fiddler say - using environment variables:

set http_proxy=http://127.0.0.1:8888
set https_proxy=http://127.0.0.1:8888
Counterinsurgency answered 8/7, 2014 at 11:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.