How to Install and Remotely Access Squid Proxy on Ubuntu 22.04

squid splash image

This tutorial provides a comprehensive guide on setting up and remotely accessing the Squid proxy server on an Ubuntu 22.04 system. Squid proxy is a popular caching and forwarding HTTP proxy server that acts as an intermediary between clients and web servers. It enables efficient caching of web content, improves browsing performance, and provides various features for network administrators to manage and control internet access.

By installing and configuring Squid proxy on an Ubuntu 22.04 system, you gain the ability to cache frequently accessed web content, reducing bandwidth usage and improving response times for subsequent requests. Additionally, Squid proxy offers features such as access control, content filtering, and user authentication. This allows you to enforce policies and restrictions for internet access within your network.

The article not only walks you through the installation process of Squid proxy on Ubuntu 22.04 but also provides instructions for remote access. This means you can send your devices traffic to the proxy server from a remote location granting you accessibility and security from anywhere.

Overall, understanding how to install and remotely access Squid proxy on Ubuntu 22.04 empowers you to optimize your network’s performance, enhance security, and efficiently manage internet access for your organization or personal use.

Update and Upgrade Ubuntu 22.04

update and upgrade ubuntu 22.04

The first thing we will need to do to install Squid Proxy is update and upgrade your system. Run the apt update and apt upgrade command below.

sudo apt update && sudo apt upgrade -y

Install Squid Proxy

install squid and apache2-utils

The next thing we need to do is install Squid proxy and Apache utilities. The utilities package will allow us to create a password authentication file for authentication our proxy users. Use the apt command below to install the two packages.

sudo apt install squid apache2-utils

Create a Credential File

touch and create squid passwords file

Now we will create a passwords file and assign the correct permissions. Squid will read this file to authenticate our proxy users. Use the below command to touch and chmod the file.

sudo touch /etc/squid/passwords && sudo chmod 777 /etc/squid/passwords

Create Authentication User

create user and password

Next create the proxy authentication user with the htpasswd command. Replace “username” with the username you want to use for logging into the proxy. After you run the command you will be asked to type and retype the password you wish to use.

sudo htpasswd -c /etc/squid/passwords username

Test Authentication

test the authentication file

Now we can test our proxy authentication file with the basic_ncsa_auth command. Run the following command and confirm you get “OK” as shown in the above image. This means that the credential file is configured properly.

/usr/lib/squid/basic_ncsa_auth /etc/squid/passwords

Backup Squid Config

backup the original squid config

After we create our credentials file we need to make a backup of the squid config. Move it to a temporary location with the command below.

sudo mv /etc/squid/squid.conf /etc/squid/squid.conf.backup

Create Squid Config File

create new squid config file

Now create a new squid config file with the nano command.

sudo nano /etc/squid/squid.conf

Add Lines to Config (Local Network Only)

add to squid config for localnet only

Once the file opens it will be blank and we need to add a few lines. Copy and paste the below config into your squid.conf file. Make sure to change the “acl localnet src 192.168.2.0/24” line to reflect your own IP range. With this configuration you will only be able to access your proxy from within the local network. If you want to access the proxy remotely skip to the next optional step. Otherwise save and close the config file.

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 24 hours
auth_param basic casesensitive off
acl authenticated proxy_auth REQUIRED
acl localnet src 192.168.2.0/24 # RFC1918 possible internal network
http_access allow localnet
http_access deny all
dns_v4_first on
forwarded_for delete
via off
http_port 8888

[optional] Add Lines to Config (Remote)

add to squid config for both wan and lan access

This step is optional, however it will allow you to access the proxy server remotely. To enable remote access replace your config with the lines shown below. Keep in mind you will also have to enable port forwarding in your router for remote access. Save and close the file.

When allowing remote access to your proxy it is recommended to configure a firewall. For guidance on this please see our How to Configure a Firewall in Linux using UFW tutorial.

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwords
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 24 hours
auth_param basic casesensitive off
acl authenticated proxy_auth REQUIRED
acl all src 192.168.2.0/24 # RFC1918 possible internal network
http_access allow all
http_access deny all
dns_v4_first on
forwarded_for delete
via off
http_port 8888

Start and Enable Squid Process

start and enable squid

The last step in the installation process is to start and enable the squid proxy service. Use the systemctl command below to complete these steps.

sudo systemctl start squid && sudo systemctl enable squid

Install Curl

install curl on separate machine

Now that the installation is complete we can test our squid proxy server. For this step you will need to install Curl onto a separate machine.

sudo apt install curl

Test the Squid Proxy Server

test the proxy with curl

After you have installed Curl run the following command. Replace “myuser:password” with the username and password you choose when you created the credential file. Additionally replace IP-ADDRESS with the IP of the Ubuntu machine with the squid proxy server.

curl --proxy-user myuser:password --proxy IP-ADDRESS:8888 https://www.google.com

Verify Curl Results

confirm curl response with proxy

If the connection to the proxy server was successful you should see a bunch of text in the Curl response. You have now successfully installed Squid proxy on Ubuntu 22.04.

[optional] Verify the Proxy Requests in the Log

confirm the connection test in the squid access log

If you would like extra verification that Squid is functioning you can check the log file. Use the tail command below and verify you see a new request appear when you run the test Curl command from above.

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

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our guide on How to Install WordPress on Ubuntu 22.04.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our Installing Elementary OS: A Comprehensive Guide for Beginners article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.

How to Install WordPress on Ubuntu 22.04

install wordpress on ubuntu splash image

In today’s tech age having a powerful and user friendly website is essential for businesses, bloggers, and individuals. WordPress a renowned content management system (CMS), has emerged as the go-to solution for creating stunning websites with ease. If you’re looking to use WordPress on your Ubuntu 22.04 server this article is your comprehensive guide to getting started.

WordPress offers a vast array of themes, plugins, and customizable features that enable you to create a unique online presence. Whether you’re a beginner or a seasoned web developer, WordPress simplifies website creation and management. Best of all it eliminates the need for extensive coding knowledge. By leveraging its intuitive interface and extensive community support, you can effortlessly establish a professional online presence.

In this step by step tutorial, we will walk you through the process of installing WordPress on Ubuntu 22.04. By following these instructions, you’ll be well-equipped to embark on your WordPress journey and start using this dynamic platform. Let’s dive in and empower your web presence with WordPress on Ubuntu 22.04.

Update and Upgrade Ubuntu

Update and Upgrade Ubuntu

The first step to installing WordPress is to update and upgrade your Ubuntu installation. Run the following command.

sudo apt update && sudo apt upgrade -y

Install Required Packages

Install Required Packages

Next you will need to install all of the required packages. Install them using the apt command below.

sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql -y

Login to the Root MySQL Account

Login to the Root MySQL Account

Once you have installed all of the required packages you will need to login to SQL. Use the below mysql command, then enter your user password to login.

sudo mysql -u root -p

Update the Database Records

Update the Database Records

After you get into mysql, run the following four mysql statements. Replace ‘wordpressuser’ and ‘password’ with the username and password you want to use for your mysql user.

CREATE DATABASE wordpress;

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';

FLUSH PRIVILEGES;

Once the mysql statements have been ran, exit the mysql command line with ‘EXIT;’.

EXIT;

Download WordPress

Download WordPress

After running your mysql commands you will need to download WordPress. First navigate to your web directory at /var/www/html.

cd /var/www/html

Then download the latest version of WordPress using the wget command.

sudo wget https://wordpress.org/latest.tar.gz

Extract the WordPress Archive

Extract the WordPress Archive

Next extract the WordPress files from the .tar.gz archive using the tar command.

sudo tar -xvzf latest.tar.gz

Move the Files to the Web Directory

Move the Files to the Web Directory

After the files have been extracted, move them to the root web directory using the mv command.

sudo mv wordpress/* .

Apply Permissions

Apply Permissions

Next apply read/write permission to the folder using the chown and chmod commands.

sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/

Move the WordPress Config File

Move the WordPress Config File

After applying the permissions, create a WordPress config file based off of the sample file. Use the following command.

sudo mv wp-config-sample.php wp-config.php

Open the WordPress Config File

Open the WordPress Config File

After creating the wp-config.php file you need to open it using the nano text editor, or your editor of choice.

sudo nano wp-config.php

Update the Config Values

Update the Config Values

Now you need to update the three lines highlighted in red. Fill out the DB_NAME, DB_USER, and DB_PASSWORD lines with the values you choose during the mysql step. Once you finish editing these lines, save and close the file.

Edit the Apache Configuration File

Edit the Apache Configuration File

Afterwards open up your Apache configuration file with nano.

sudo nano /etc/apache2/sites-enabled/000-default.conf

Scroll down until you see the line “DocumentRoot /var/www/html”, add the following to the line underneath.

DirectoryIndex index.php index.html

Once you have made your changes save and close the file.

Enable Apache a2enmod

Enable Apache a2enmod

Now we have to enable the Apache extension “a2enmod”. Enable it using the below command. If it was successful you should see “Enabling module rewrite”.

Restart Apache

Restart Apache

Finally we will restart Apache to apply all of our changes. Use the systemctl restart command below.

sudo systemctl restart apache2

Navigate to the WordPress Setup Page

Navigate to the WordPress Setup Page

Now you can open a web browser and navigate to your servers IP address. You can find it by opening a terminal window on Ubuntu and running the “ip a” command. Once you arrive to the page you will be asked to select your language before continuing.

Configure the WordPress Site

Configure the WordPress Site

On the next page you will be asked for the title of your site, your username, password, and email. After you fill out these fields select “Install WordPress” to complete the installation.

WordPress Successfully Installed on Ubuntu 22.04

Wordpress Successfully Installed on Ubuntu 22.04

Once you see this page your WordPress installation is complete. Click “Log In” to begin using WordPress. You have now successfully installed WordPress on Ubuntu Server 22.04.

Questions?

If you have any questions or comments feel free to leave them below.

Related Resources

View our How to Setup Nginx as a Reverse Proxy on Ubuntu 22.04 LTS.

Learn How to Install Ubuntu Server 22.04 [Step by Step].

Check out our How to Easily Create a Bootable Linux USB Drive using Rufus article.

View our How to Setup an SFTP Server on Ubuntu 22.04 using OpenSSH tutorial.

Learn more cool things in Linux with our Linux Tutorials.

View all of our available online tools and converters at Formatswap.com.