Buy fast & affordable proxy servers. Get 10 proxies today for free.
Download our Proxy Server Extension
Products
© Webshare Proxy
payment methods

Configuring proxy settings on Linux can enhance security, privacy, and control over network traffic. Whether you need to route your traffic through an HTTP or SOCKS5 proxy, or you’re managing a forward or reverse proxy, Linux offers flexible options for setup. In this guide, we’ll cover the differences between HTTP and SOCKS5 proxies, explore the use cases for forward and reverse proxies, and walk you through the steps to configure both types of proxies on your Linux system—either through the terminal or by using Squid.
A proxy in Linux acts as an intermediary between your device and the internet, routing your network traffic through a separate server. This setup can be used for various purposes, such as enhancing privacy, controlling access, or bypassing restrictions. In Linux, proxies are commonly configured for both HTTP and SOCKS5 protocols, depending on your needs. By setting up a proxy server in Linux, you can manage how traffic is handled across networks.
In Linux, proxies can be configured as either forward or reverse proxies, depending on the use case. A forward proxy in Linux routes client requests to the internet, masking the client’s IP address and allowing you to bypass restrictions, apply caching, or increase security. For instance, setting up a forward proxy in Linux can help anonymize your browsing or regulate internet access in a network, making it a common choice for personal and organizational use.
A reverse proxy in Linux, on the other hand, manages traffic from external users to internal servers. It acts as a gateway that forwards client requests to the appropriate backend servers, commonly used for load balancing, improving performance, and enhancing security in server environments. Linux-based reverse proxies are often deployed in web server setups to efficiently distribute traffic.
In this article, we’ll focus on configuring a forward proxy in Linux, as it's the most relevant for managing outbound traffic from clients.
In Linux, you can configure either an HTTP or SOCKS5 proxy based on your specific network needs.
Here’s a comparison of the two:
<table border="1" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th>Feature</th>
<th>HTTP Proxy (Linux)</th>
<th>SOCKS5 Proxy (Linux)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Traffic Type</td>
<td>HTTP/HTTPS only</td>
<td>Any traffic (HTTP, FTP, P2P, etc.)</td>
</tr>
<tr>
<td>Use Cases</td>
<td>Web browsing, filtering, caching</td>
<td>Versatile (P2P apps, gaming, torrenting)</td>
</tr>
<tr>
<td>Speed</td>
<td>Faster for web traffic</td>
<td>Slower but handles more types of traffic</td>
</tr>
<tr>
<td>Security</td>
<td>Basic encryption via HTTPS</td>
<td>Supports authentication, no encryption by default</td>
</tr>
</tbody>
</table>Before configuring proxy settings on Linux, you need to ensure your system is properly set up. Here’s what you need to get started:
sudo apt update && sudo apt install curlsudo dnf install curlHTTP proxy setup methods on LinuxThere are several ways to set up an HTTP proxy in Linux. We’ll explore two common methods: configuring the proxy using the terminal and using Squid, a popular proxy management tool.Using TerminalThe terminal method is simple and works well for temporary proxy settings. It allows you to export the proxy settings to your environment variables.
export http_proxy=http://username:password@proxyserver:port/
export https_proxy=http://username:password@proxyserver:port/Replace username, password, proxyserver, and port with your actual proxy credentials and details. If the proxy doesn’t require authentication, omit the username:password@ part.
nano ~/.bashrcAdd the following lines at the end of the file:
export http_proxy=http://username:password@proxyserver:port/
export https_proxy=http://username:password@proxyserver:port/Save the file and apply the changes:
source ~/.bashrccurl -I https://www.example.comSquid is a powerful, full-featured HTTP proxy server commonly used in Linux environments for caching and web traffic filtering. Below are the steps to install and configure Squid for HTTP proxying.
Install Squid: First, install Squid on your Linux system:some text
sudo apt update
sudo apt install squidsudo dnf install squidOpen the configuration file for editing:
sudo nano /etc/squid/squid.confLook for the line that says http_port 3128. This is the default port for Squid, but you can change it if needed by specifying a different port number.
Next, allow access to the proxy by adding an access control list (ACL). For example, to allow access from all local network clients, add the following lines:
acl localnet src 192.168.0.0/16 # Define your local network range
http_access allow localnetauth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/squid_passwd
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
http_access allow auth_usersYou’ll need to create the squid_passwd file and add your users with hashed passwords. Use the htpasswd tool to create a password file:
sudo htpasswd -c /etc/squid/squid_passwd your_usernameUse -c only for the first user to create the file; for subsequent users, omit -c.
sudo systemctl restart squidtail -f /var/log/squid/access.logIn addition to HTTP proxies, you can configure SOCKS5 proxies on Linux, which provide more flexibility for handling various types of traffic. Below are two common methods: setting up a SOCKS5 proxy via the terminal and using Squid.
One of the simplest ways to set up a SOCKS5 proxy on Linux is by using terminal commands. A common tool for this is ssh, which can create a secure SOCKS5 tunnel.
ssh -D 1080 -q -C -N username@remote_host-D 1080: This opens a dynamic port forwarding (SOCKS5 proxy) on port 1080.
-q: Runs SSH in quiet mode.
-C: Enables compression to improve performance.
-N: Tells SSH to not execute any remote commands, just create the tunnel.
Replace username and remote_host with your SSH credentials and remote server’s IP or hostname. This command will create a SOCKS5 proxy on your local machine (localhost) on port 1080.
export ALL_PROXY=socks5://localhost:1080This will apply the SOCKS5 proxy to all outgoing traffic for terminal-based applications that respect the ALL_PROXY variable.
curl --socks5 localhost:1080 https://www.example.comIf the proxy is correctly set up, the request will go through the SOCKS5 proxy.
Squid is a robust proxy server that can be configured to support SOCKS5. While it is natively an HTTP proxy server, additional configuration or external modules can be used to enable SOCKS5 proxying. Below are the general steps for configuring Squid for SOCKS5 proxying.
sudo apt install dante-serversudo dnf install dante-serverHere’s the example configuration:
logoutput: stderr
internal: eth0 port = 1080
external: eth0
method: username
user.privileged: proxyuser
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
protocol: tcp udp
}Set the internal interface and port for SOCKS5 (port = 1080). Use eth0 as the external and internal interfaces (replace it with your actual network interface if necessary).
sudo systemctl start danted
sudo systemctl enable dantedcache_peer localhost parent 1080 0 no-query defaultsudo systemctl restart squid
sudo systemctl restart dantedConfiguring proxy settings on Linux provides a flexible and powerful way to enhance your network's security and manage internet traffic. Whether using HTTP or SOCKS5 proxies, these methods ensure better control over your connections, making Linux an ideal platform for proxy management.
Proxy in Ubuntu: Terminal and Squid Methods Explained