Install Proxy Server Linux

I

How To Setup and Configure a Proxy Server – Squid Proxy

How To Setup and Configure a Proxy Server – Squid Proxy

A proxy server has many use cases. it could range from personal internet access to restrict organization systems/servers to access the external world or to limit external internet access for a set of servers on the cloud.
The best way to configure a proxy server is by using the Squid proxy. It is a widely used proxy server.
In this article, we have covered the following.
Install proxy serverConfigure the proxy serverConfigure basic proxy authentication.
Note: This tutorial is tested on CentOS 7. For Ubuntu setup, check this tutorial – Squid Proxy Setup On Ubuntu
Install Proxy Server: Squid Proxy
Step1: Update the server
sudo yum update -y
Step 2: Configure EPEL repo.
sudo yum -y install epel-release
sudo yum -y update
sudo yum clean all
Step 3: Install squid
sudo yum -y install squid
Step 4: Start and enable squid server.
sudo systemctl start squid
sudo systemctl enable squid
Step 5: Check the status of squid server.
sudo systemctl status squid
Configure Proxy Server: Squid Proxy
All the configurations for the squid server are present in /etc/squid/ file.
Configure proxy Sources To Access Internet
First, you need to configure the sources from which squid proxy should accept connections. For example, you might need to access this proxy server only from your home network or from specific CIDR ranges.
You can add a source IP range with an ACL using the following format.
acl localnet src 110. 220. 330. 0/24
Open /etc/squid/nffile and add the source add as shown below. Change the IP to the desired network/IP source based on your needs. In the following example, we have added a single source IP.
Restart the proxy server after making the ACL changes.
sudo systemctl restart squid
Test proxy Server Connectivity
Test if the proxy server is working using a simple curl request. Use the following curl format. By default squid proxy runs on 3128 port.
curl -x :3128 -L
Configure Proxy Authentication
Along with access ACL’s, you can add basic authentication to your proxy server for extra security. Follow the steps given below for setting up a basic auth for the squid proxy server.
Step 1: Install d-tools
sudo yum -y install d-tools
Step 2: Create a passwd file and make squid as the file owner.
sudo touch /etc/squid/passwd && sudo chown squid /etc/squid/passwd
Step 3: Add pxuser to the password file using htpasswd utility. It will prompt for a custom password. Enter a strong password you need. This username and password will be used for all connections through this proxy.
sudo htpasswd /etc/squid/passwd pxuser
Step 4: Open squid config file.
sudo vi /etc/squid/
Add the following to the config file and save it.
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
_access allow auth_users
Step 5: Now, restart squid server for the configuration changes to take place.
Step 6: Now if you test the proxy connection using curl, you will get the “authentication required message” as shown below.
Now, test the connectivity with proxy user and password we configured in step 3. An example syntax is shown below.
curl -x –proxy-user pxuser:12345 -I With username and password, your proxy request should go through.
Blocking Websites
Another great use of the proxy server is restricting the website access. Follow the steps below for creating a block list.
Step 1: Open a blocked list file.
sudo vi /etc/squid/blocked_sites
Add the websites to be blocked in the file. For example,
Step 2: Open the squid config file.
Add the following to the ACL list.
acl blocked_sites dstdomain “/etc/squid/blocked_sites”
_access deny blocked_sites
Step 3: Restart the squid server.
Now if you try to access the blocked site through the proxy, you will get a forbidden message as shown below.
Established in 2014, a community for developers and system admins. Our goal is to continue to build a growing DevOps community offering the best in-depth articles, interviews, event listings, whitepapers, infographics and much more on DevOps.
How to Set up Linux Proxy Server with advantages? - eduCBA

How to Set up Linux Proxy Server with advantages? – eduCBA

Introduction to Linux Proxy Server
In today’s world, the internet has become more common than ever. Everyone can access the internet with ease. As they “With great power comes great responsibility”. Internet is not secure to use freely, people can easily get your information if you have not taken certain steps to secure yourself whilst using the internet. Major problems of using browsing without a secured internet channel are Identity theft and security breaches. One of the best ways to protect yourself from hackers is to use a proxy server. Let’s see how you can secure your Linux system.
Proxy Servers
A proxy server is like a protective barrier between your system and the internet. These software applications that run on your fire-wall machine in order to prevent indirect Internet access to your network. Proxy servers are intermediate servers separating end users from the websites they browse. When you are using a proxy server, internet traffic goes through a proxy server on its way to the address requested by you. The same happens for the data received from the address. Later proxy server pushes the data it received from the website to you.
Advantages of using a Linux Proxy server
Apart from securing your system proxy server has the following advantages:
Anonymity: The web server you use can only see the IP address of the proxy and not your system.
Control: If you are the owner of a website, you can see who visits your website. You can choose who visits your website. If you have blocked someone from your website they would get a message saying something like “site unavailable”
Caching: You can save bandwidth if I cache a web site.
Malware: You can intercept unwanted things and stop junks at the proxy.
Load Balancing: Efficiently distributing incoming network traffic among servers.
How to Set Up a Linux Proxy Server
There are many Linux proxy servers but one of the most efficient and common proxy servers is Squid. Squid is a free and easy to use Linux proxy server. It is an open-source forward proxy server with many functionalities. It is being used by many organizations for their forward proxy needs.
1. The first thing to do is to update to the latest package list. Use the “Sudo apt-get update”.
2. Install Squid Proxy server.
3. Start and enable the proxy server.
4. To see the status use “systemctl status” command. The status of which should be active.
5. To see which port the proxy is running use “netstat –tnlp”.
The primary use case for most of us have is to connect to the internet through a proxy server. If you want to connect to the internet through your proxy, you need to configure ACLs (Access Control List) in your squid configuration. Edit file to allow access to certain IP ranges.
To block certain websites from being accessed add them to the proxy block list.
Now you are good to go.
Risks of using Linux Proxy server
Here are the possible risks of using a proxy server which is given below:
Free Proxy Server Risks: Free Proxy Servers Will Use Ads to Get Revenue so You Will Be Annoyed by All the Ads when Using a Free Proxy.
Browsing Log: Proxy servers have your browsing history and your original IP
No Encryption: If you use a proxy server without encryption, you might as well not use a proxy server
Conclusion
Hey, you just learned how to configure a Linux proxy server on your system. Now you can securely browse websites without fearing for Identity theft or hacking. For all the new posts regarding Linux make sure to keep an eye on eduCBA.
Recommended Articles
This is a guide to Linux Proxy Server. Here we discuss the advantages as well as steps of setting up a Linux proxy server along with the risks of using it. You may also look at the following articles to learn more –
Introduction to Linux
Linux vs Android
Types of Shells in Linux
Linux Operators
How to Set Up & Install Squid Proxy Server on Ubuntu 18.04

How to Set Up & Install Squid Proxy Server on Ubuntu 18.04

Introduction
Squid is a Linux-based proxy application. The Squid proxy server is used for filtering traffic, security, and DNS lookups.
Also, Squid can speed up a web server by caching resources. The Squid Proxy allows a server to cache frequently visited web pages. When the user requests a web page or file, the request goes directly to the proxy server — an intermediary device between the user’s device and the internet. The proxy server pulls up the resources and relays them to the user.
This guide will walk you through how to set up and install Squid Proxy server on Ubuntu.
Prerequisites
An Ubuntu operating systemAccess to a terminal window/command line (Ctrl-Alt-T)An Ubuntu user with root or sudo privilegesThe apt package installer, included by defaultA text editor, such as nano
Installing Squid Proxy on Ubuntu
Step 1: Refresh the Software Repositories
Ensure you’re working with the latest software version available.
Launch a terminal window, and enter the following:
sudo apt-get update
Step 2: Install Squid Package on Ubuntu
To install Squid, run the command:
sudo apt-get install squid
The system should prompt for confirmation – enter Y and allow the process to complete itself.
Configuring Squid Proxy Server
The Squid configuration file is found at /etc/squid/
1. Open this file in your text editor with the command:
sudo nano /etc/squid/
2. Navigate to find the _port option. Typically, this is set to listen on Port 3218. This port usually carries TCP traffic. If your system is configured for traffic on another port, change it here.
You may also set the proxy mode to transparent if you’d like to prevent Squid from modifying your requests and responses.
Change it as follows:
_port 1234 transparent
3. Navigate to the _access deny all option. This is currently configured to block all HTTP traffic. This means no web traffic is allowed.
Change this to the following:
_access allow all
4. Navigate to the visible_hostname option. Add any name you’d like to this entry. This is how the server will appear to anyone trying to connect. Save the changes and exit.
5. Restart the Squid service by entering:
sudo systemctl restart squid
Configure Squid Client
All this configuration has been done to set up your Squid proxy server. Now, switch to your client machine and open your web browser.
If you’re using Firefox, you can find the proxy settings under:
Menu > Options > Network Settings > Settings
Tick the radio button for Manual proxy configuration.
If you’ve entered a hostname in Step 4, you should be able to enter that name plus the port you have designated. Otherwise, use the IP address for the system hosting your Squid proxy.
To test it, you can visit – if your proxy is working, your IP address should display as the proxy server’s IP address.
Add Squid ACL
Note: After each of these steps, you should save and exit, then restart the Squid service to apply the new configuration.
Create an access control list by editing the file again, as in Step 4.
Add a new line as follows:
acl localnet src 192. 168. 0. 15
This will create a rule that only allows the system at this IP address to connect. It is recommended that you comment the line to identify the rule:
acl localnet src 192. 15 # test computer
Anything after the # sign is ignored by Squid.
You can specify a range of IP addresses as follows:
acl localnet src 192. 15/30
Open Ports
To open a specific port, add the following:
acl Safe_ports port 123 # Custom port
Configure Proxy Authentication
This forces users to authenticate to use the proxy.
Start by installing apache2-utils:
sudo apt-get install apache2-utils
Create a passwd file, and change the ownership to the Squid user proxy:
sudo touch /etc/squid/passwd
sudo chown proxy: etc/squid/passwd
Add a new user and password
1. To add a new user to Squid, use the command:
sudo htpasswd /etc/squid/passwd newuser
The system will prompt you to enter and confirm a password for newuser.
2. Edit the /etc/squid/ file, and add the following command lines:
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
_access allow auth_users
Block Websites on Squid Proxy
1. Create and edit a new text file /etc/squid/ by entering:
2. In this file, add the websites to be blocked, starting with a dot:..
Note: The dot specifies to block all subsites of the main site.
3. Open the /etc/squid/ file again:
4. Add the following lines just above your ACL list:
acl blocked_websites dstdomain “/etc/squid/”
_access deny blocked_websites
Commands When Working with the Squid Service
To check the status of your Squid software, enter:
sudo systemctl status squid
This will tell you whether the service is running or not.
To start the service enter:
sudo systemctl start squid
Then set the Squid service to launch when the system starts by entering:
sudo systemctl enable squid
You can re-run the status command now to verify the service is up and running.
To stop the service, use the command:
sudo systemctl stop squid
To prevent Squid from launching at startup, enter:
sudo systemctl disable squid
Conclusion
If you’ve followed along closely, you should now have a basic understanding of how Squid works, and how to install and configure Squid Proxy on Ubuntu.
Proxy servers are a valuable tool for securing network traffic, preventing attacks and restricting access.
Check out our article on how to set up your Ubuntu system to work with a proxy server to configure your Ubuntu machine to use a proxy.
Interested in setting up this application on a different OS? You may want to check out how to install Squid on CentOS 7.

Frequently Asked Questions about install proxy server linux

How do I setup a proxy server in Linux?

How to Set Up a Linux Proxy ServerThe first thing to do is to update to the latest package list. Use the “Sudo apt-get update”.Install Squid Proxy server.Start and enable the proxy server.To see the status use “systemctl status” command. … To see which port the proxy is running use “netstat –tnlp”.

How do I setup a proxy server on Ubuntu?

Installing Squid Proxy on Ubuntu. Step 1: Refresh the Software Repositories. Step 2: Install Squid Package on Ubuntu.Configuring Squid Proxy Server.Configure Squid Client. Add Squid ACL. Configure Proxy Authentication. Add a new user and password. Block Websites on Squid Proxy.Commands When Working with the Squid Service.Feb 15, 2019

What is proxy server Linux?

A proxy server is a computer that acts as an intermediary between a desktop computer and the internet and allows a client machine to make an indirect connection to network servers and services.Mar 30, 2017

About the author

proxyreview

If you 're a SEO / IM geek like us then you'll love our updates and our website. Follow us for the latest news in the world of web automation tools & proxy servers!

By proxyreview

Recent Posts

Useful Tools