6

I'm using my college network.Here i have set proxy to 10.30.0.1:8080 to access internet.But i'm not able to set proxy in Raspberry Pi 3.

asked Jun 16, 2017 at 20:21
1

3 Answers 3

9

For apt:

Navigate to the following folder as follows:

cd /etc/apt/apt.conf.d

Create a file called 10proxy:

sudo nano 10proxy

Without authentication add this line:

Acquire::http::Proxy "http://proxyaddress:proxyport/";

Or with authentication add this line:

Acquire::http::Proxy "http://username:password@proxyaddress:proxyport/";

Make sure to include the / at the end.

For everything else:

Edit this file:

sudo nano /etc/environment

Add this line (with authentication):

export http_proxy="http://username:password@proxyaddress:port/"

Or without authentication:

export http_proxy="http://proxyaddress:port/"

answered Jun 16, 2017 at 20:39
9
  • Does this set the http_proxy and https_proxy environment variables? Or does this only setup a proxy for apt? Commented Jun 16, 2017 at 21:06
  • I made a mistake! See my edited answer for the full solution Commented Jun 16, 2017 at 21:14
  • The method for apt is working.But for everything else: method is not working.Can you tell me that what do you mean by 'host in 'export http_proxy="host:port" ? I have tried by putting Proxy Address 10.30.0.1:8080 but it is not working. @Veroxi .Thanks for previous answer. Commented Jun 20, 2017 at 2:52
  • host should be just the IP (not the port) Commented Jun 20, 2017 at 6:16
  • 1
    Updated this answer to replace the word "host" with "proxyaddress" in case anyone is confused with the local host. Commented Nov 29, 2017 at 8:57
3

As of Raspbian GNU/Linux 10 (buster), the syntax for defining environment variables has changed from the older syntax shown in other answers. The export keyword is no longer supported in the /etc/environment file, and causes errors like this:

invalid variable name "export http_proxy", ignoring.

Edit /etc/environment and set 3 lines to proxy both secure insecure requests:

http_proxy="http://username:password@proxyaddress:port/"
https_proxy="http://username:password@proxyaddress:port/"
no_proxy="localhost,127.0.0.1"

Restart the system for changes to take effect. After rebooting, open a terminal and type the following to see if the variables are present:

env | grep proxy

Note that Chromium (the default browser) often caches pages even on a "hard refresh," so your proxy settings may not appear to work. Use an incognito window to open a test site.

answered Dec 19, 2019 at 18:31
2

The proxy on any Linux environment can be set using two files

  1. /etc/environment

  2. /etc/apt/apt.conf.d/01proxy (sometimes this file doesnt exist so create one)

now firstly see what are the default setting in these two files using cat command

1.cat /etc/environment ==> create a backup if something goes wrong

2.cat /etc/apt/apt.conf.d/01proxy

using a simple bash script you can disable or enable proxy for terminal written by me : https://github.com/k1941996/Proxy_switcher/blob/master/switch_proxy.txt

simply change the proxy according to your network.

Add these files in your .bashrc file and you can directly switch proxy using simple commands like enableproxy and disableproxy

answered Oct 13, 2018 at 7:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.