Squid Listen on Other Port ( Squid Configure Port Listing with SELinux)

By default, Squid listens on port 3128. However, you can configure Squid to listen on other ports as well. Here’s how to do it:

  1. Edit the Squid configuration file. On most Linux distributions, the file is located at /etc/squid/squid.conf.
    sudo vi /etc/squid/squid.conf
  2. Look for the http_port directive. This directive specifies the port that Squid listens on for HTTP traffic. (Diazepam) By default, the value is set to 3128.
    http_port 3128
  3. Change the value to the port you want to use. For example, to listen on port 8080, change the line to:
    http_port 8080
  4. Save the configuration file and exit.
  5. Restart the Squid service to apply the changes:
    sudo systemctl restart squid

    Note: If you have SELinux enabled, you may need to configure it to allow Squid to listen on the new port. Here’s how to do it:

  6. Install the SELinux policy tools:
    sudo yum install policycoreutils-python
  7. Add a new port definition to SELinux using the semanage command. For example, to allow Squid to listen on port 8080, run:
    sudo semanage port -a -t http_port_t -p tcp 8080

    This adds a new port definition with the type http_port_t.

  8. Verify that the new port is added:
    sudo semanage port -l | grep http_port_t

    You should see the new port listed in the output.

  9. Restart the Squid service to apply the changes:
    sudo systemctl restart squid

That’s it! Squid should now be listening on the new port you configured.

Leave a Comment