6

I set the proxy using system setting -> Network -> Network Proxy. I then clicked on "Apply system wide", put my password, and nothing else.

michele@rserver-VirtualBox:~$ wget http://bbc.co.uk
--2014-09-30 13:02:20--  http://bbc.co.uk/
Resolving datapx01-wcg (datapx01-wcg)... 10.123.7.31
Connecting to datapx01-wcg (datapx01-wcg)|10.123.7.31|:8080... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: http://www.bbc.co.uk/ [following]
--2014-09-30 13:02:21--  http://www.bbc.co.uk/
Reusing existing connection to datapx01-wcg:8080.
Proxy request sent, awaiting response... 200 OK
Length: 103020 (101K) [text/html]
Saving to: ‘index.html’

100%[======================================>] 103,020      190KB/s   in 0.5s   

2014-09-30 13:02:21 (190 KB/s) - ‘index.html’ saved [103020/103020]

Instead using sudo:

michele@rserver-VirtualBox:~$ sudo wget http://bbc.co.uk
[sudo] password for michele: 
--2014-09-30 13:02:30--  http://bbc.co.uk/
Resolving bbc.co.uk (bbc.co.uk)... 212.58.246.104, 212.58.244.20, 212.58.246.103, ...
Connecting to bbc.co.uk (bbc.co.uk)|212.58.246.104|:80... failed: Connection timed out.

I am on 14.04 and I didn't have this issue before upgrading from 12.04 yesterday. Please tell me what other info you need.

Michele
  • 251
  • 1
  • 3
  • 8

2 Answers2

13

In case anybody wonders:

The issue here, is that when sudoing, a newenvironment is loaded, meaning that http_proxy is no longer set.

To resolve this issue you can add Defaults env_keep += "http_proxy https_proxy" to your /etc/sudoers file in order to keep those variables when switching to the secure path.

Reference: https://help.ubuntu.com/community/EnvironmentVariables

daniel f.
  • 846
  • super answer!! worked in CentOS 7 as well. – Ubuntuser Apr 09 '18 at 08:52
  • Just a note: this would still requires the respective environment variables to be set inside the profile of the user, who belongs to the sudoers. Add export http_proxy=... and export https_proxy=... to .bashrc or whatever your user's profile file is called. Also I recommend putting no_proxy, which is quite common for company networks, where internal network locations (e.g. intranet web portal) often not only do not require but will not work if going through proxy. – rbaleksandar Apr 01 '22 at 06:21
1

Open /etc/apt/apt.conf file in Terminal and set your proxy setting as following:

Acquire::http::proxy "http://user:pass@host:port/";
Acquire::https::proxy "https://user:pass@host:port/";
Acquire::ftp::proxy "ftp://user:pass@host:port/";
Acquire::socks::proxy "socks://user:pass@host:port/";

Replace user with your username, pass with your password, host with proxy-webaddress and port with a portnumber.

αғsнιη
  • 35,660