Detailed tutorial on installing Squid proxy on CentOS7 [with tutorial]

The following is a detailed tutorial on installing and configuring a Squid proxy server on CentOS 7, with a tutorial on how to use it:

Install Squid proxy server:

  1. Open a terminal and log in to the CentOS system as root user.
  2. Install the Squid package with the following command:

    sudo yum install squid
  3. After the installation is complete, open Squid's configuration file with a text editor  /etc/squid/squid.conf:

    sudo vi /etc/squid/squid.conf
  4. Make configuration modifications as needed. Here are some commonly used configuration options:

    • Configure Squid's listening port (default is 3128), if you need to change the port number, find the following line and modify the port number:

      http_port 3128
    • Configure the network or IP address that is allowed to access. Locate the following line and add or modify the access control rule:

      acl allowed_network src <network>/<netmask>
      http_access allow allowed_network
    • If you need to enable logging, uncomment the following lines and configure further logging as needed:

      #access_log /var/log/squid/access.log squid
    • Modify other configuration options as needed.
  5. Save and close the file: Press  Escthe key to exit edit mode, then enter  :wqSave and Exit.
  6. Start the Squid service:

    sudo systemctl start squid
  7. Configure firewall: If you have a firewall enabled on your system, you need to allow Squid communication. Execute the following command to allow Squid's HTTP traffic to pass through the firewall:

    sudo firewall-cmd --add-service=http --permanent
    sudo firewall-cmd --reload

Use Squid proxy server:

Now, Squid proxy server has been installed and started on your CentOS system. Here are some commonly used tutorials:

  1. Configure client devices or applications: On client devices or applications that need to use a proxy, configure the proxy server address and port. By default, Squid listens on port 3128, so specify the proxy server address in the configuration as the IP address and port number 3128 of the CentOS system.
  2. Test Proxy Connection: Perform a connection test in the client device or application through the configured proxy server address and port. You can test that the proxy is working by visiting a website or using the curl command:

    curl -x <proxy_server_address>:3128 http://www.example.com
  3. Monitor Squid logs: If logging is enabled in Squid's configuration file, you can monitor Squid's access logs to see proxy server activity and access:

    tail -f /var/log/squid/access.log

Through the above steps, you have successfully installed and configured

A Squid proxy server is installed and can be used in client devices or applications for proxy access. According to your needs, you can further customize the configuration of Squid, such as adding more access control rules or configuring advanced functions. Note that Squid has many other features and options, you can refer to Squid's official documentation for more detailed information and configuration guides.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/131258898