0% found this document useful (0 votes)
10 views8 pages

Configure Squid Forward Proxy on Ubuntu

A forward proxy acts as an intermediary between client devices and the internet, facilitating access control, logging, and caching. The document provides a step-by-step guide to install and configure Squid as a forward proxy on Ubuntu, including optional authentication setup. Squid is an open-source proxy server that enhances web browsing speed, controls internet usage, and monitors traffic.

Uploaded by

md.rakibul2828
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

Configure Squid Forward Proxy on Ubuntu

A forward proxy acts as an intermediary between client devices and the internet, facilitating access control, logging, and caching. The document provides a step-by-step guide to install and configure Squid as a forward proxy on Ubuntu, including optional authentication setup. Squid is an open-source proxy server that enhances web browsing speed, controls internet usage, and monitors traffic.

Uploaded by

md.rakibul2828
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Forward proxy configuration:

✅ What is a Forward Proxy?


A forward proxy sits between client devices (like your
browser) and the internet. It forwards client requests to
external servers and returns the responses. It’s often used
for:
 Internet access control
 Logging and monitoring
 Speeding up access with caching

🧰 Step-by-Step: Install & Configure Squid Forward


Proxy on Ubuntu
🔹 Step 1: Update System
bash
Copy code
sudo apt update
sudo apt upgrade

🔹 Step 2: Install Squid Proxy


bash
Copy code
sudo apt install squid
🔹 Step 3: Backup Default Config
sudo cp /etc/squid/[Link]
/etc/squid/[Link]

🔹 Step 4: Configure Squid


Edit the config file:
sudo nano /etc/squid/[Link]
Look for the following lines and modify/add them:
Allow LAN Access (e.g., [Link]/24):
acl localnet src [Link]/24
http_access allow localnet
Optional: Allow localhost
acl localhost src [Link]
http_access allow localhost
Set Listening Port (default is 3128)
http_port 3128
(Optional) Hide Client Info
conf
via off
forwarded_for off
request_header_access Allow deny all
request_header_access Authorization
deny all
request_header_access From deny all
request_header_access Referer deny all
request_header_access User-Agent deny
all
request_header_access Via deny all
request_header_access X-Forwarded-For
deny all
Press Ctrl+O to save and Ctrl+X to exit.

🔹 Step 5: Restart Squid


sudo systemctl restart squid

🔹 Step 6: Configure UFW (Firewall) to Allow Proxy


Port
sudo ufw allow 3128/tcp

🔹 Step 7: Configure Client Devices


Set the proxy IP and port (e.g.,
[Link]:3128) in:
 Browser > Network Settings
 or system-wide in /etc/environment:
export
http_proxy="[Link]
export
https_proxy="[Link]

🔐 Optional: Enable Authentication


(Username/Password)
1. Install Apache utilities:
sudo apt install apache2-utils
2. Create password file:
sudo htpasswd -c /etc/squid/passwords
myuser
3. Edit [Link]:
auth_param basic program
/usr/lib/squid/basic_ncsa_auth
/etc/squid/passwords
auth_param basic realm Proxy
acl authenticated proxy_auth REQUIRED
http_access allow authenticated
4. Restart Squid:
sudo systemctl restart squid

🧪 Test Your Proxy


You can use:
curl -x [Link]
ip:3128 [Link]
Or set it in your browser’s proxy settings and browse the
internet.

Let me know if you want:


 Transparent proxy setup
 Logging & usage reports
 Content filtering setup
 HTTPS interception (advanced)

✅ What is a Forward Proxy? — Brief Explanation with


Example
A forward proxy is a server that acts as an intermediary
between a client (like your computer) and the internet.
When a client makes a request (e.g., to visit a website),
the proxy forwards that request to the internet on behalf
of the client, then sends the response back to the client.

🔹 Example Scenario:
Imagine you're using a computer in a school network.
1. You open your browser and try to visit
[Link]
2. Instead of directly connecting to [Link],
your request goes to the forward proxy server.
3. The proxy checks if you're allowed to access that site.
o If allowed, it connects to [Link],

fetches the content, and sends it back to your


browser.
o If blocked (e.g., Facebook or YouTube), it denies

the request.

🔹 Use Cases:
 Access Control: Block websites like social media in
offices.
 Monitoring: Keep logs of user activity.
 Caching: Serve frequently visited websites faster by
saving copies.
✅ What is Squid Proxy?
Squid is a popular open-source proxy server that
supports:
 Forward Proxy
 Caching
 Access control
 Content filtering
It mainly works for HTTP, HTTPS, and FTP protocols,
and is commonly used to:
 Speed up web browsing via caching
 Control internet usage in networks (like schools or
companies)
 Monitor and log traffic
 Restrict access to certain websites

🔹 How Squid Works (Simple Flow)


[ Client ] → [ Squid Proxy ] →
[ Internet ]
 Client sends a request (e.g., for a website).
 Squid checks if it has a cached copy.
o If yes: returns cached copy (faster).

o If no: fetches from the internet and caches it.


🔹 Key Features of Squid
Feature Description
Speeds up repeated requests by storing
Caching
copies of web content.
Define which users/IPs can access the
Access Control
internet.
Keeps detailed logs of all client
Logging
requests.
Supports username/password login (via
Authentication
NCSA, LDAP, etc).
Bandwidth Can limit download speeds or block
Control large files.
Supports SSL tunneling via CONNECT
HTTPS Support
method.

🔹 Where Squid is Used


 Schools – Block social media and adult content
 Offices – Save bandwidth and restrict certain
websites
 ISPs – Improve response time and reduce bandwidth
cost

You might also like