How to set up a squid proxy with multiple IPs
This guide is available in template form for Virtuozzo VPS servers. Customers can install servers using the CentOS 7 + Squid Proxy Operating System template for a quick setup.
The Squid proxy software used to be extremely popular when the internet wasn’t using https and SSL certificates. Now people prefer to use a SOCKS proxy server because they offer more configuration options and are generally seen as more secure. Here we are going to set up a Squid proxy server and configure it for use with multiple IPs.
To create your Squid proxy you will need at minimum one of our NVMe VPS with 5GB of space, 1GB ram and some v-swap. You should have unlimited bandwidth and a subnet of IPs.
Update & Install Squid Proxy
Squid is contained in the epel repository so issue the command below. This will ;
1. Update your server
2. Install the epel reporitory
3. Install Nano
4. Install Squid Proxy serer
5. Stop & Disable FirewallD
6. Provide the status of Squid
yum update -y ; yum -y install epel-release ; yum install nano -y ; yum -y update ; yum clean all ; yum -y install squid ; systemctl start squid ; systemctl enable squid ; systemctl stop firewalld ; systemctl disable firewalld ; systemctl status squid
Squid mostly comes ready to use but your going to want to ensure only users you want to connect to the proxy can connect. In this guide we are going to secure Squid by only allowing access from certain IPs.
First, more the original squid.conf file out of the way.
mv /etc/squid/squid.conf /etc/squid/old-squid.conf
Now create a new squid.conf and paste the below code to the file. We have added notations to the file for the sections you need to change.
# Example rule allowing access from your local networks. # Adapt to list your (internal) IP networks from where browsing # should be allowed acl localnet src ALLOW-CONEECTIONS-FROM/32 # IP in /32 format acl localnet src 10.0.0.0/8 # RFC1918 possible internal network acl localnet src 172.16.0.0/12 # RFC1918 possible internal network acl localnet src 192.168.0.0/16 # RFC1918 possible internal network acl localnet src fc00::/7 # RFC 4193 local private network range acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT acl myip_51_xxx_xx_15 myip 51.xx.xx.15 tcp_outgoing_address 51.xx.xx.15 myip_51_xx_xx_15 # # Recommended minimum Access Permission configuration: # # Deny requests to certain unsafe ports http_access deny !Safe_ports # Deny CONNECT to other than secure SSL ports http_access deny CONNECT !SSL_ports # Only allow cachemgr access from localhost http_access allow localhost manager http_access deny manager # We strongly recommend the following be uncommented to protect innocent # web applications running on the proxy server who think the only # one who can access services on "localhost" is a local user #http_access deny to_localhost # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # # Example rule allowing access from your local networks. # Adapt localnet in the ACL section to list your (internal) IP networks # from where browsing should be allowed http_access allow localnet http_access allow localhost # And finally deny all other access to this proxy http_access deny all # Squid normally listens to port 3128 http_port 3128 # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/spool/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/spool/squid # # Add any of your own refresh_pattern entries above these. # refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320
acl localnet src ALLOW-CONNECTIONS-FROM/32 # IP in /32 format
Replace this section with the IP you want to allow to connect to your proxy. To allow more IPs just copy the section. It will look like this once edited.
acl localnet src 192.168.0.1/32 # Notation
Configure Additional IPs in Squid
TO configure any additional IPs you have to add a section for each IP. In the squid.conf file you will see the following section;
acl myip_51_xxx_xx_15 myip 51.xx.xx.15 tcp_outgoing_address 51.xx.xx.15 myip_51_xx_xx_15
Edit this section and fill out your IP address. The section will look like this once complete;
acl myip_51_199_10_15 myip 126.96.36.199 tcp_outgoing_address 188.8.131.52 myip_51_199_10_15
To add more IPs just copy the section and edit it with your other IP details. Here I added two more IPs to the squid.conf file.
acl myip_51_199_10_15 myip 184.108.40.206 tcp_outgoing_address 220.127.116.11 myip_51_199_10_15 acl myip_51_199_10_16 myip 18.104.22.168 tcp_outgoing_address 22.214.171.124 myip_51_199_10_16 acl myip_51_199_10_17 myip 126.96.36.199 tcp_outgoing_address 188.8.131.52 myip_51_199_10_17
Save & Restart Squid
That the configuration of squid complete. Save the squid.conf file and restart squid. You can then start using your new proxy with additional IPs.
systemctl restart squid
We have a range of IPs located in different countrys around the world. These are ideal for Squid. You can order additional IPs from your client area (Services > View Addons)
How was this article? – How to set up a squid proxy with multiple IPs
You might also like
More from Dedicated Servers
Cloud-init is a popular way to automate deployments of instances in a cloud or none cloud environment. To save having …
Ioncube Loaders are a piece of software that is used to protect the underlying code in PHP applications. Its aim …