TRENDING
  • Linux
  • Shell Script
  • Cloud
  • DevOps
  • About US
SUBSCRIBE
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Reading: How to Configure Squid Proxy Server on AlmaLinux / Rocky Linux
Share
TechBrownTechBrown
Aa
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Search
  • CLOUD
  • DEVOPS
  • LINUX
  • SHELL SCRIPT
Follow US
© 2014 - 2022 TechBrown. All Rights Reserved.
Linux

How to Configure Squid Proxy Server on AlmaLinux / Rocky Linux

January 19, 2015
Share
4 Min Read
SHARE
Contents
Working Principle of Transparent Proxy ServerSquid Proxy Server quick key pointsSquid Proxy Server Installation and ConfigurationLinux Client Side Configuration

First of all we know about Proxy Server before knowing Transparent Proxy Server. Proxy servers are used to share an Internet connection with clients. A Proxy Server can be configured as the transparent Proxy Server. To share the Internet connection and Caching web server on AlmaLinux / Rocky Linux / Amazon Linux.

First of all to store web pages locally to improve performance. Proxy firewall to control access to the Internet. Squid Proxy is the most widely used open source proxy these software is used for Transparent Proxy Server.

Working Principle of Transparent Proxy Server

02-How-proxy-works-1
03-How-proxy-works-2-1024x546 04-How-proxy-works-3 05-How-proxy-works--1024x546

Squid Proxy Server quick key points

  • Packages – squid*.rpm
  • Port Numbers – 3128 (default)
  • Configuration File – /etc/squid/squid.conf
  • Service / Daemon – squid

Squid Proxy Server Installation and Configuration

Firstly in Step-I (Install the Squid proxy packages)

# yum install squid*

Secondly in Step-II (Edit the configuration file)

# vi /etc/squid/squid.conf

First of all Modify the following parameters

http_port 3128 transparent
visible_hostname linux?squid
cache_dir ufs /var/spool/squid 100 16 256
acl our_networks src 192.168.0.0/24
acl business_hours time S M T W H F A 09:00?17:30
acl test url_regex www.yahoo.com
http_access allow our_networks business_hours test

After that Step-III (Run the Natting script)

# vim transparent_proxy.sh

Then Add The given line

#!/bin/sh
SQUID_SERVER="192.168.0.12"
# Interface connected to Internet
INTERNET="eth0"
# Interface connected to LAN
LAN_IN="eth1"
# Squid port
SQUID_PORT="3128"
# DO NOT MODIFY BELOW
# Clean old firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Load IPTABLES modules for NAT and IP conntrack support
modprobe ip_conntrack
modprobe ip_conntrack_ftp
# For win xp ftp client
#modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
# Unlimited access to loop back
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
# Allow UDP, DNS and Passive FTP
iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT
# set this system as a router for Rest of LAN
iptables --table nat --append POSTROUTING --out-interface $INTERNET -j
MASQUERADE
iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT
# unlimited access to LAN
iptables -A INPUT -i $LAN_IN -j ACCEPT
iptables -A OUTPUT -o $LAN_IN -j ACCEPT
# Load IPTA
# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT)
aka transparent proxy
iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to
$SQUID_SERVER:$SQUID_PORT
# if it is same system
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port
$SQUID_PORT
# DROP everything and Log it
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP

After that Run the script

# bash transparent_proxy.sh

Finally in Step-IV (Restart the squid service)

# service squid restart

Linux Client Side Configuration

Firstly in Step-I (Refresh the network)

# netconfig

Econdly in Step-II (Give Gateway ip as Proxy)

07-Linux-Client-Configuration-1024x546

Finally in Step-III (Open browser and start browsing)

08-Linux-Client-Configuration-1024x546

Congratulations now you have configured the Squid Proxy Server on AlmaLinux / Rocky Linux / Amazon Linux.

You Might Also Like

How to Optimize MySQL Performance on AlmaLinux / Rocky Linux

How to Enable TLS 1.3 on Apache and Nginx

5 Security Tips to Protect your WordPress Website from Hackers

How to Enable AES-128 Bit SSL Cipher with TLS 1.3 on Nginx Web Server

How to Set Up NGINX Web Server on AlmaLinux / Rocky Linux

Sign Up For Newsletter

Be keep up! Get the latest articles delivered straight to your inbox.

TechBrown Solutions January 19, 2015
Share this Article
Facebook TwitterEmail Print
Share
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

TRENDING

AWS

How to Encrypt Amazon EBS Volumes using AWS KMS Customer Managed Keys

Linux

How to Install Sphinx-Doc on Ubuntu / AlmaLinux / Rocky Linux

Linux

How to Configure ISCSI Target Server on AlmaLinux / Rocky Linux

Linux

How to Fix Modem Manager is not Working on AlmaLinux / Rocky Linux

You Might Also Like

Linux

How to Optimize MySQL Performance on AlmaLinux / Rocky Linux

October 19, 2021
Linux

How to Enable TLS 1.3 on Apache and Nginx

March 14, 2021
Linux

5 Security Tips to Protect your WordPress Website from Hackers

November 8, 2020
Linux

How to Enable AES-128 Bit SSL Cipher with TLS 1.3 on Nginx Web Server

November 7, 2020

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

Follow US on Social Media

Facebook Twitter Youtube Rss

© 2014 - 2022 Techbrown. All Rights Reserved.

  • About Us
  • Terms of Service
  • Cookie Policy
  • Privacy Policy
By using this site, you agree to the Privacy Policy, Cookie Policy and Terms of Service.
Accept

Removed from reading list

Undo
AdBlock Detected
Our site is an advertising supported site. Please whitelist to support our site.
Okay, I'll Whitelist
Welcome Back!

Sign in to your account

Lost your password?