Sign up Download
  • Tiếng Việt
  • English
  • Español
  • Bahasa Indonesia
  • Squid Proxy, a powerful tool to enhance security and optimize network performance. The following article will provide you with useful information about what Squid Proxy is, its main applications and functions. At the same time, this article from GenFarmer also provides detailed instructions on how to install Squid Proxy on the Ubuntu 20.04 operating system, helping you to easily deploy and use this tool.

    What is Squid Proxy?

    Squid Proxy is an open-source proxy server that is popular and widely used worldwide. It acts as an intermediary between client devices and Internet servers, helping to improve performance and security.

    Squid Proxy works by caching copies of frequently accessed web resources. When a new request arrives, Squid checks if the resource is already in the cache. If so, it sends the resource from the cache to the user, significantly reducing page load times and saving bandwidth.

    In addition to improving speed, Squid Proxy also offers many security and access control features. It can filter malicious websites, block ads, restrict access to inappropriate content, and protect users’ personal information.

    What is Squid Proxy?
    What is Squid Proxy?

    Prerequisites for installing Squid Proxy on Ubuntu 20.04

    Before you start installing Squid Proxy on Ubuntu 20.04, make sure your system meets the following requirements:

    • A server running Ubuntu 20.04 with root or sudo privileges.
    • A stable Internet connection.
    • Basic knowledge of the Linux command line.
    • An SSH tool like PuTTY on Windows or Terminal on macOS/Linux to connect to the remote server.
    Prerequisites for installing Squid Proxy on Ubuntu 20.04
    Prerequisites for installing Squid Proxy on Ubuntu 20.04

    Guide to installing Squid Proxy on Ubuntu 20.04

    The Squid package is available in the default Ubuntu 20.04 repositories. To install it, you just need to execute the following two commands:

    sudo apt update
    sudo apt install squid

    Once the installation is complete, the Squid service will start automatically. To check the status of the Squid service, you can use the following command:

    sudo systemctl status squid

    If the installation is successful, you will see a result similar to the following:

    squid.service - Squid Web Proxy Server
    Loaded: loaded (/lib/systemd/system/squid.service; enabled; vendor preset: enabled)
    Active: active (running) since Fri 2020-10-23 19:02:43 UTC; 14s ago
    Docs: man:squid(8)
    Guide to installing Squid Proxy on Ubuntu 20.04
    Guide to installing Squid Proxy on Ubuntu 20.04

    Basic Squid Service Configuration

    Squid’s main configuration file is located at /etc/squid/squid.conf. In this file, you will find comments describing the configurations and their corresponding actions. You can create a separate configuration file and use the include directive to add it to the main configuration file.

    Before making any changes, back up the sample configuration file with the command:

    sudo cp /etc/squid/squid.conf{,.original}

    Then, open the configuration file with your preferred text editor (e.g., nano):

    sudo nano /etc/squid/squid.conf

    By default, Squid listens on port 3128 on all network interfaces of the server. If you want to change the port for a specific interface, find the line starting with http_port and specify the IP address of the interface along with the new port. If no interface is specified, Squid will listen on all interfaces.

    # Squid normally listens to port 3128 http_port IP_ADDR:PORT

    Most users use Squid on all interfaces with the default port.

    Squid allows you to control client access to web resources through Access Control Lists (ACLs). By default, access is only from localhost. If all clients using this proxy have a static IP address, you can create an ACL to specify the allowed IPs. Alternatively, you can also require authentication to use Squid.

    Instead of adding IP addresses directly to the main configuration file, you can create a separate file to store the allowed IP addresses, for example, /etc/squid/allowed_ips.txt with the following content:

    192.168.33.1 # All other allowed IPs

    Once done, reopen the configuration file and create a new ACL named allowed_ips to allow access via the http_access directive:

    # ...
    acl allowed_ips src "/etc/squid/allowed_ips.txt"
    # ...
    #http_access allow localnet
    http_access allow localhost
    http_access allow allowed_ips
    # And finally, deny all other access to this proxy
    http_access deny all

    Note that the order of the http_access lines is very important. Make sure to add the http_access allow allowed_ips line before the http_access deny all line.

    The http_access directive works like a firewall rule. Squid reads the rules from top to bottom, and when a rule is triggered, the rules below it are not executed.

    After editing the configuration file, you need to restart the Squid service to apply the changes:

    sudo systemctl restart squid
    Basic Squid Service Configuration
    Basic Squid Service Configuration

    Commands for working with Squid Service

    If restricting access based on IP is not suitable for your needs, you can configure Squid to use a back-end to authenticate users. Squid supports Samba, LDAP, and HTTP basic auth. In this guide, I will use the basic auth method, a simple authentication method based on the HTTP protocol.

    To create an encrypted password, you can use the openssl tool. The command below will create a USERNAME:PASSWORD pair and save it to the /etc/squid/htpasswd file:

    printf "USERNAME:$(openssl passwd -crypt PASSWORD)\n" | sudo tee -a /etc/squid/htpasswd

    For example, to create a user cloudzone with the password Cl@udZ@ne, you would type:

    printf "cloudzone:$(openssl passwd -crypt 'Cl@udZ@ne')\n" | sudo tee -a /etc/squid/htpasswd

    Next, you need to enable HTTP basic authentication and specify the file containing the login information in Squid’s configuration file.

    Open the main configuration file:

    sudo nano /etc/squid/squid.conf

    Add the following lines to the configuration file:

    # ...
    auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid/htpasswd
    auth_param basic realm proxy acl authenticated proxy_auth REQUIRED
    # ...
    #http_access allow localnet
    http_access allow localhost
    http_access allow authenticated
    # And finally deny all other access to this proxy
    http_access deny all

    Finally, you need to restart the Squid service for the changes to take effect:

    sudo systemctl restart squid
    Commands for working with Squid Service
    Commands for working with Squid Service

    Firewall Configuration

    To open the port for Squid, you need to enable UFW Profiles with the following command:

    sudo ufw allow 'Squid'

    If Squid is running on a different port, for example, port 8888, you can use the command below:

    sudo ufw allow 8888/tcp

    Configuring browser to use Proxy

    Firefox

    • In the top right corner, click the ☰ icon to open the Firefox menu.
    • Select Preferences.
    • Scroll down to the Network Settings section and click the Settings… button.
    • In the new dialog box, select Manual proxy configuration.
    • Enter the IP of the server where Squid is installed in the HTTP Host field and enter 3128 in the Port field.
    • Check the Use this proxy server for all protocols checkbox.
    • Finally, click OK.
    To check, you can open google.com, type “what is my ip”, and you will see the IP of the Squid server. If you want to revert to the default settings, go back to Network Settings, select Use system proxy settings, and save. Alternatively, you can also use plugins like FoxyProxy to configure the proxy for Firefox.

    Chrome

    Google Chrome uses the system’s proxy settings by default. If you don’t want to change the system proxy settings, you can use addons like SwitchyOmega or launch Chrome from the command line. To open Chrome with a new profile and connect to the Squid server, use the commands below: Linux:
    /usr/bin/google-chrome \
    --user-data-dir="$HOME/proxy-profile" \
    --proxy-server="http://SQUID_IP:3128"
    macOS:
    "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
    --user-data-dir="$HOME/proxy-profile" \
    --proxy-server="http://SQUID_IP:3128"
    Windows:
    "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" ^
    --user-data-dir="%USERPROFILE%\proxy-profile" ^
    --proxy-server="http://SQUID_IP:3128"

    Conclusion

    Squid Proxy is a powerful tool that helps enhance security, improve performance, and control internet access. With the detailed guide on how to install and configure Squid Proxy on Ubuntu 20.04, you can now deploy this solution to protect and optimize your network system.

    However, to effectively manage and automate tasks related to Phonefarm, Boxphone, and Box phone Farm, you need a more comprehensive solution. GenFarmer is the number 1 platform in this field, providing advanced security features, preventing account locks, and allowing users to manage a large number of accounts from any platform.

    With the combination of Squid Proxy and GenFarmer, you will have a solid, secure, and easily scalable system. GenFarmer helps simplify management and automate tasks, while Squid Proxy ensures network security and optimizes performance. Leverage the power of both of these solutions to take your business operations to the next level.


    Leave a Reply

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

    0
    YOUR CART
    • No products in the cart.