20.06.2025

How to set up proxy on Linux client?

A proxy server is used to redirect network traffic from a client to a target resource. It can perform caching, access control, anonymization, or bypass restrictions.

In this guide, we will look at how to set up a proxy on a client machine (Linux) and how to deploy a simple proxy server based on squid.

Configuring a proxy on the client

To configure a proxy server on the client side, you must specify the proxy address and port in the system or user environment variables.

Step 1. Setting environment variables

Add the following lines to your ~/.bashrc or ~/.bash_profile:

export http_proxy="http://:"
export https_proxy="http://:"
export ftp_proxy="http://:"
export no_proxy="localhost,127.0.0.1,::1"

Example:

export http_proxy="http://192.168.1.100:3128"
export https_proxy="http://192.168.1.100:3128"

Apply changes:

source ~/.bashrc

Screenshot № 1 — Export

Step 2. Installing a proxy in apt (for Debian/Ubuntu)

Create or edit the file /etc/apt/apt.conf.d/95proxies:

Acquire::http::Proxy "http://192.168.1.100:3128/";
Acquire::https::Proxy "http://192.168.1.100:3128/";

Configuring a proxy server (Squid)

Squid is a popular caching proxy server with flexible configuration.

Step 1. Install Squid

For Debian / Ubuntu:

sudo apt update
sudo apt install squid -y

Screenshot № 2 — Squid

For CentOS / RHEL:

sudo yum install squid

Step 2. Configure Squid

Open the configuration file:

sudo nano /etc/squid/squid.conf

Find and edit the following parameters:

##Allow access from your subnet:

acl localnet src 192.168.1.0/24
http_access allow localnet

##Specify the port (default is 3128):

http_port 3128

Save the changes and restart the service:

sudo systemctl restart squid
sudo systemctl enable squid

Screenshot № 3 — Server deploy

Step 3. Checking the work

From the client, make a request:

curl -x http://192.168.1.100:3128 http://example.com

If the proxy works, you will receive an HTML response from the site.

For authentication, add auth_param to the Squid configuration. The work logs are located in /var/log/squid/access.log. Proxy configuration is a useful tool for administering network traffic. You can set proxy server parameters both on the client and run your own server based on Squid. This will provide control, acceleration and filtering of connections.