In the modern Internet environment, using an HTTP proxy to protect privacy, improve access speed or access regionally restricted websites has become a common need. Today, I will detail how to build an HTTP proxy server on CentOS system. I hope this article can provide you with some help.
preliminary
Before we start building the HTTP proxy server, we need to do some preparation. First, you need a server running CentOS operating system. If you don't have a server yet, consider renting one from a cloud service provider. Second, you need to have some basic knowledge of Linux, as this article will cover some command line operations.
Installing Squid
Squid is a very popular HTTP proxy server software. We will use Squid to build our HTTP proxy server. First, use the following command to update your system's packages:
sudo yum update -y
Next, install Squid:
sudo yum install squid -y
After installation, Squid automatically creates a configuration file. This configuration file is located in the/etc/squid/squid.conf
The
Configuring Squid
Next, we need to configure Squid. First, open the configuration file:
sudo nano /etc/squid/squid.conf
In the configuration file, you will see a lot of comments and default configurations. We need to make some changes. First, find and uncomment the following lines:
http_access allow all
Next, we need to specify the port on which Squid is listening. Find the following line:
http_port 3128
You can change 3128 to the port number you want, such as 8080. when the change is complete, save and close the file.
Starting Squid
Once the configuration is complete, we can start the Squid service:
sudo systemctl start squid
To ensure that Squid starts automatically after a system reboot, we also need to execute the following command:
sudo systemctl enable squid
Squid is now running on your server. You can find out more about Squid by visiting thehttp://your_server_ip:3128
to test your HTTP proxy server.
Setting up the firewall
To make sure your proxy server is working properly, we need to do some configuration of the firewall. Use the following command to open the port used by Squid:
sudo firewall-cmd --permanent --add-port=3128/tcp
sudo firewall-cmd --reload
This way, the firewall allows external access to your HTTP proxy server.
Verify Proxy Server
Now you can verify that your HTTP proxy server is working correctly by using your browser or other tools. In your browser, open the proxy settings, enter your server's IP and port number, and try to access a website. If everything works, you should be able to access the Internet through the proxy server.
Security settings
By default, Squid allows anyone to use your proxy server. To improve security, you can add some access control rules to your configuration file. For example, only allow specific IP addresses to access your proxy server:
acl allowed_ips src 192.168.1.0/24
http_access allow allowed_ips
http_access deny all
Save and close the file, then restart the Squid service:
sudo systemctl restart squid
summarize
With the above steps, you have successfully built an HTTP proxy server on your CentOS system. Although the whole process involves some command line operations, but as long as you follow the steps, I believe you will be able to successfully complete. I hope this article is helpful to you, and I wish you happy using it!