Would you like to learn how to install Varnish and Nginx on Ubuntu Linux?In this tutorial, we are going to show you all the steps required to perform the Varnish installation on Ubuntu Linux in 5 minutes or less.
• Ubuntu 18.04
• Ubuntu 19.10
• Varnish 6.1.1
• Nginx 1.16.1
In our example, the Varnish service will listen on the TCP port 80.
In our example, the Nginx service will listen on the TCP port 8080.
Varnish – Related Tutorial:
On this page, we offer quick access to a list of tutorials related to Varnish.
Tutorial – Varnish Installation on Ubuntu Linux
Install the Varnish service.
Verify the default.vcl configuration file.
Here is the default.vcl configuration file content.
The Varnish service default configuration expects a web server to be running on the localhost on port 8080.
Edit the configuration file named Varnish located inside the directory named default.
Here is the Varnish configuration file, before our configuration.
Here is the Varnish configuration file, after our configuration.
In our example, we configured the Varnish service to run on port 80.
The Varnish service was configured to connect to a web server running on port 8080 of the localhost.
The Varnish service was configured to allocate 256mb of memory for cache.
Next, edit the Varnish service configuration file.
Here is the file, before our configuration.
Here is the file, after our configuration.
In our example, we configured the Varnish service to run on port 80.
Reload the Varnish service configuration.
Restart the Varnish service.
Verify if the Varnish service is listening on the TCP port 80.
Here is the command output.
You have finished the Varnish service configuration on Ubuntu LInux.
Tutorial Varnish – Nginx Installation on Ubuntu Linux
Install the Nginx service.
Edit the Nginx configuration file named default.
Here is the file, before our configuration.
Change the Nginx default port from 80 to 8080.
Here is the file, after our configuration.
Restart the Nginx service.
Verify if the Nginx service is listening on the TCP port 8080.
Here is the command output.
You have finished the Nginx configuration to use the Varnish service.
Tutorial Varnish – Testing your installation
After finishing installation, you need to test your Varnish configuration.
Open a browser software and enter the external IP address of your Varnish server.
In our example, the following URL was entered in the Browser:
• http://200.200.200.200
The Varnish service will communicate with the Nginx service and answer your request.
Use the following command to verify if the Varnish service is answering your request.
Here is the command output.
As you can see on the header, the Varnish service is answering the user request.