Internet and social media users who care about network security and privacy, are familiar with Proxy servers. Providing a gateway between them and the internet, a Proxy Server is a system that prevents cyber attackers and malware from access into the internal networks. In this article, you will learn How to Setup Proxy on Ubuntu.
Regardless you are comfortable with the graphical user interface or command line, this guide will be useful for you with presenting both methods to configure Proxy on Ubuntu. Follow the below steps to add a layer of security to your Ubuntu, protect your system from internet threats, and speed it up.
Prerequisites to Setup Proxy on Ubuntu
To let this tutorial works correctly, provide the options below and move on.
- A system running Ubuntu.
- Access to Terminal and GUI.
- A non-root user with
sudo
privileges. - A Proxy. In order to set up your considered computer to serve as a proxy, refer to Install and Setup Squid Proxy on Ubuntu.
Benefits of Configuring a Proxy Server on Ubuntu
Previously, you learned What is Proxy Server and How it works. Now, you know that to prevent cyber attackers from entering your private network, you need to use it. This part is written to convince you to setup Proxy on Ubuntu.
The extra security layer that a proxy server provides is also valuable when in conjunction with an encrypted web gateway or other email security tools. So, depending on the safety of the traffic or the capacity of your network or individual workstations, you can filter it.
Some people use proxies for private targets, including disguising their location while accessing internet movies, for instance. However, a Proxy might be used by a business to carry out a number of significant responsibilities such as:
- Increase security.
- Prevent snoopers from monitoring the internet activity of your employees.
- To prevent crashes, balance internet traffic.
- Controlling the websites that staff members and employees can access at work.
- Caching files or compressing incoming information can reduce bandwidth usage.
Setup Proxy on Ubuntu Using GUI
As we mentioned, there are two different methods to Setup Proxy on Ubuntu. Follow the steps below to configure Proxy on Ubuntu.
1. Open Ubuntu’s Settings
Open Ubuntu’s main Settings to access proxy settings.
2. Select the Network Setting
On the left side of the window, select Network Settings > Network Proxy.
Step 3. Enter the IPs and Ports
Select “Manual” when the pop-up window appears and enter your Proxy info (Server’s hostname or IP address, and port numbers). Then, close all the windows and click on Apply system wide to let the changes apply.
Setup Proxy on Ubuntu Using Command Line
Let’s go through the second method of setting up a proxy on Ubuntu which is Terminal. Using Terminal in setting up the proxy gives you additional options and flexibility. It is possible to set up a proxy for one user or for all users, both temporarily and permanently.
Before diving into different modes of setting up proxy with Ubuntu desktop terminal, review its basic syntax:
proxy_http=username:password@proxy-server-ip:port
proxy_https=username:password@proxy-server-ip:port
proxy_ftp=username:password@proxy-server-ip:port
Setup Temporary Proxy for a Single User
Obviously, this is useful when you prefer to not use proxy settings forever. After a system reboot, the temporary connection resets and lasts until you reboot your system. Use the following command to set proxy environment variables temporarily.
This is the syntax for establishing a temporary proxy connection.
export HTTP_PROXY=[username]:[password]@[proxy-web-or-IP-address]:[port-number]
export HTTPS_PROXY=[username]:[password]@[proxy-web-or-IP-address]:[port-number]
export FTP_PROXY=[username]:[password]@ [proxy-web-or-IP-address]:[port-number]
...
export NO_PROXY=localhost,127.0.0.1,::1
Specify the port number after the proxy address (web or IP). Add your proxy username and password as the initial values if the proxy server asks for authentication. The NO_PROXY line’s directive instructs the system to disregard the proxy for local traffic.
Setup Permanent Proxy for a Single User
Setting up a permanent Proxy for a single user is possible by editing the ~/.bashrc file. Login to your Ubuntu server with the user you wish to set the proxy for. Open the terminal interface and edit the ~/.bashrc file.
sudo nano ~/.bashrc
Then, add the following lines at the end of the .bashrc file.
export HTTP_PROXY="[username]:[password]@[proxy-web-or-IP-address]:[port-number]"
export HTTPS_PROXY="[username]:[password]@[proxy-web-or-IP-address]:[port-number]"
export FTP_PROXY="[username]:[password]@ [proxy-web-or-IP-address]:[port-number]"
...
export NO_PROXY="localhost,127.0.0.1,::1"
Save and exit the file when you are finished.
Afterward, run the following command to make your updated proxy settings active for the current session:
source ~/.bashrc
Setup Permanent Proxy for All Users
In this part of setup proxy on Ubuntu, you will learn how to set up a permanent Proxy for all users. to do this, set up global variables in /etc/environment file. firstly, log in (with root or administrative user) and edit the /etc/environment file:
sudo nano /etc/environment
Likewise, include the lines from below in the file. Remember to update them with your proxy domains, IP addresses, and ports.
export HTTP_PROXY="[username]:[password]@[proxy-web-or-IP-address]:[port-number]"
export HTTPS_PROXY="[username]:[password]@[proxy-web-or-IP-address]:[port-number]"
export FTP_PROXY="[username]:[password]@ [proxy-web-or-IP-address]:[port-number]"
...
export NO_PROXY="localhost,127.0.0.1,::1"
When you’re done, save and shut the file. To activate the proxy settings, you must log out and then log back in.
Setup Proxy for APT
To install some packages from Ubuntu repository, create a separate proxy configuration file for APT since it does not use system environment variables. To set up proxy settings for APT, you can create a proxy configuration file.
In the /etc/apt directory, create or update the file apt.conf to specify proxy settings for apt:
sudo nano /etc/apt/apt.conf
Add the following lines to the file:
Acquire::http::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";
Acquire::https::Proxy "http://[username]:[password]@ [proxy-web-or-IP-address]:[port-number]";
When you’re done, save and shut the file. Any package can now be installed on your PC.
To install the package by specifying your proxy settings, run:
'http://username:password@proxy-server-ip:8080' apt-get install package-name
You’re all set. Update all the commands of this tutorial with your proxy data.
FAQ
Is proxy server a VPN?
No, A virtual private network (VPN) typically safeguards and encrypts all system-wide data and traffic. Proxies can be configured to only work with certain apps and services. They are not required to be system-wide. Both have advantages and disadvantages.
Which one to choose? Proxy or VPN?
Due to the fact that users frequently require secure data transmission in both directions, a VPN is more suited for commercial use. In the wrong hands, company information, and employee data can be quite valuable, and a VPN offers the encryption you need to keep it secure. A proxy server might be a suitable option for private use where a security breach would only harm you and no other users. You can also combine the two technologies, especially if you want to restrict which websites people on your network can access while still encrypting their conversations.
How to get the username, pass, IP, and ports of the proxy?
You must contact your proxy service provider. Your proxy provider may give you a domain or an IP. They also might provide you with a proxy that needs authentication or one that doesn't.
Conclusion
In this article, you learned How to setup Proxy on Ubuntu. You can do this using two different methods of GUI and Terminal. You should now be able to modify the proxy settings of your system for a single user or for the entire system, both temporarily and permanently. If you follow the above steps properly, you can setup Proxy on Ubuntu without any errors but do not hesitate to contact us if you encounter any problems. Our technical support team will try their best to solve your problems.