Ubuntu, as a popular Linux distribution, provides users with a wealth of network configuration options, including setting up a proxy server. A proxy server can act as an intermediary between you and the Internet, helping you bypass certain network restrictions, increase access speed, or enhance privacy protection. This article will detail how to configure a proxy server in Ubuntu.
Understand the basic concept of proxy server
A proxy server is a computer located between the client and the server. It receives requests from the client and forwards these requests to the target server. After the server responds, the proxy server returns the response to the client. In this way, the proxy server can hide the client's real IP address and provide additional network security and privacy protection.
Configure HTTP and HTTPS proxies
In Ubuntu, you can configure HTTP and HTTPS proxies through the graphical interface or the command line.
Method 1: Configure proxies through the graphical interface‌
- Open System Settings‌: Click the System Settings icon in the upper-right corner of the screen and select "Settings".
- ‌Enter Network Settings‌: In the Settings menu, select "Network" or "Network and Internet" (the specific name may vary depending on the Ubuntu version).
- ‌Configure proxies‌: In the Network Settings page, find the "Proxy" option and click to enter.
- ‌Set proxy address and port‌: In the proxy settings page, you can configure the address and port of HTTP, HTTPS, and SOCKS proxies separately. If you need to set proxy exceptions for specific addresses or domains, you can add them in "Addresses that do not use proxy" or similar options.
- ‌Save settings‌: After completing the proxy configuration, click the Save or Apply button to make the settings take effect.
Method 2: Configure proxies through the command line
If you prefer to use the command line, you can configure HTTP and HTTPS proxies by modifying environment variables.
‌1. Open Terminal‌: In Ubuntu, you can open the terminal by pressing Ctrl+Alt+T shortcut keys.
‌2. Set Environment Variables‌: Use the export
command to set the proxy environment variables. For example, to set the HTTP proxy, you can use the following command:
export http_proxy=http://your-proxy-server:port/
export https_proxy=https://your-proxy-server:port/
Replace your-proxy-server
and port
with your proxy server address and port number.
3‌. Verify proxy settings‌: You can test whether the proxy settings are effective by running curl
or wget
command. For example:
curl -I http://example.com
If the proxy settings are correct, you should be able to see the HTTP header information returned through the proxy server.
Configure global proxy
In some cases, you may need to configure a global proxy for the entire system. This can be done by modifying the system configuration file or using network management tools.
Method 1: Modify the system configuration file
1‌. Open the configuration file‌: You can edit the system configuration file through a text editor such as nano
, vim
, or gedit
. For example, to edit the environment variable configuration file, you can use the following command:
sudo nano /etc/environment
2‌. Add proxy settings‌: In the configuration file, find the http_proxy
and https_proxy
variables (if they don't exist, add them) and set them to your desired proxy server address and port number.
3‌. Save and exit‌: When you are done editing, save the file and exit the editor.
4‌. Restart system‌: You may need to restart the system or re-login to your user account for the configuration to take effect.
Method 2: Use network management tools
Ubuntu also provides some network management tools, such as NetworkManager
, which allows you to configure the global proxy through a graphical interface or command line. You can use the nmcli
command line tool to set the proxy.
‌1. Open the terminal‌: Similarly, open the terminal by pressing the Ctrl+Alt+T shortcut key.
2‌. Set global proxy‌: Use the nmcli command to set the global proxy. For example:
nmcli con mod <connection_name> ipv4.proxy-method manual ipv4.proxy <proxy_server>:<port>
nmcli con mod <connection_name> ipv6.proxy-method manual ipv6.proxy <proxy_server>:<port>
Replace <connection_name>
with your network connection name, and replace <proxy_server>
and <port>
with your proxy server address and port number.
3‌. Reconnect to the network‌: After completing the settings, you need to reconnect to the network for the changes to take effect. You can reconnect to the network through the nmcli
command or the graphical interface.
Notes
Proxy server stability‌: Make sure the proxy server you use is stable and reliable to avoid network interruptions or request failures.
‌Privacy and security‌: Although proxy servers can hide your real IP address, free proxy servers may have security risks and network instability. Therefore, when choosing a proxy server, try to avoid using free proxies.
‌Compliance‌: When using a proxy server, make sure your behavior complies with local laws, regulations and ethical standards.
Conclusion
Proxy servers in Ubuntu can be implemented in a variety of ways, depending on your needs and preferences. Whichever method you choose, you need to make sure that the proxy server address and port number are correct and that the proxy server itself is available.
Top comments (0)