Menu
User

DropVPS Team

Writer: Cooper Reagan

how to setup proxy server in Ubuntu?

how to setup proxy server in Ubuntu?

Publication Date

02/24/2025

Category

Articles

Reading Time

3 Min

Table of Contents

Setting up a proxy server in Ubuntu can be a great way to manage internet access, enhance security, and improve performance. In this guide, we will walk you through the steps to configure a proxy server on your Ubuntu machine. Whether you want to use Squid, a popular caching proxy, or a simple HTTP proxy, we’ve got you covered.

Step 1: Update Your System

Before installing any packages, it’s a good idea to update your system to ensure you have the latest software.

sudo apt update
sudo apt upgrade

Step 2: Install Squid Proxy Server

Squid is one of the most popular proxy servers available. You can easily install it using the following command:

sudo apt install squid

Step 3: Configure Squid

After installing Squid, you need to configure it to suit your needs. The main configuration file is located at /etc/squid/squid.conf. Open it in your favorite text editor:

sudo nano /etc/squid/squid.conf

Basic Configuration

  1. Define the HTTP Port: By default, Squid listens on port 3128. You can change it if necessary.

    http_port 3128
  2. Allow Access: By default, Squid denies all access. To allow access from your local network, you need to add an ACL (Access Control List). For example, if your local network is 192.168.1.0/24, add the following lines:

    acl localnet src 192.168.1.0/24
    http_access allow localnet

     

  3. Deny All Other Access: To ensure that only your specified network can access the proxy, add this line at the end:
    http_access deny all

Example Configuration

Here’s a simple configuration snippet you might use:

http_port 3128

acl localnet src 192.168.1.0/24
http_access allow localnet
http_access deny all

Step 4: Restart Squid

Once you’ve made your changes, save the file and restart the Squid service to apply the configuration:

sudo systemctl restart squid

Step 5: Configure Firewall

If you have a firewall running, make sure to allow traffic on the port you configured Squid to listen on (default is 3128):

sudo ufw allow 3128

Step 6: Test Your Proxy Server

To ensure your proxy server is working, you can use a web browser or a command line tool like curl. Configure your browser or tool to use the proxy at http://your_server_ip:3128.

For testing with curl, use the following command:

curl -x http://your_server_ip:3128 http://example.com

You should see the HTML output of the requested page if everything is configured correctly. Setting up a proxy server in Ubuntu using Squid is straightforward and can significantly improve your network performance and security. By following these steps, you now have a basic proxy server running on your Ubuntu machine. For further customization and advanced features, you may explore the extensive Squid documentation and community resources available online.

Linux VPS
U
Loading...

Related Posts