2.2 C
Amsterdam
Saturday, December 5, 2020

How to Install Varnish with Apache on CentOS 7

Must read

How to change the MAC address in Windows 10

Hello! How are you? Today we will see how to change the MAC address on a computer with Windows 10. In fact, it is...

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...
Muhammad Nabeel
Muhammad Nabeel
Network and System Administrator

Varnish is an HTTP optimizer designed for content-heavy dynamic web sites and APIs. In contrast to other web accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed as an HTTP accelerator. Varnish is focused exclusively on HTTP, unlike other proxy servers that often support FTP, SMTP and other network protocols.

In this article, you will learn that how to install and configure varnish HTTP accelerator as a reverse proxy for Apache/Http server.

Step 1: Install and configure Apache on CentOS 7

Install Apache/Http using below command

# yum install httpd -y

After installation, start and enable httpd service using below commands.

# systemctl start httpd
# systemctl enable httpd

Use below command to check httpd default port, you will see that it is running on port 80.

# netstat -plntu

Now Configure Apache on port 8080

By default Apache server runs on port 80 but we will configure it to run on port 8080.
In order to do that we have to edit its configuration file “httpd.conf”

Use below command to edit httpd.conf file.
And change the default port 80 to 8080 on the “Listen” line

# vi /etc/httpd/conf/httpd.conf

Save changes and exit.

Now restart the Apache/Httpd service and run again netstat command to verify it is running on port 8080.

# systemctl restart httpd
# netstat -plntu

Step 2: Install and configure Varnish

First Install EPEL Repo using the below command.

# yum install epel-release -y

Now install Varnish using the below command.

# yum install varnish -y

After installation, start and enable varnish service using below commands.

# systemctl start varnish
# systemctl enable varnish

Use below command to check varnish default ports, you will see that it is running on port 6081 and 6082.

# netstat -plntu

Configure Varnish as reverse proxy for Apache

Use below command to edit varnish.params file.
And change its default port 6081 to http port 80 on the line VARNISH_LISTEN_PORT.

# vi /etc/varnish/varnish.params

save changes and exit.

Now restart the varnish service and run again netstat command to verify it is running on port 80.

# systemctl restart varnish
# netstat -plntu

Congratulations, Varnish HTTP Accelerator has been installed successfully and now it acts as a reverse proxy for Apache web server.

Step 3: Configure Firewalld

In this step, we will add HTTP and HTTPS services so that our web server can run publically.

Install and enable firewalld using below commands

# yum install firewalld -y
# systemctl start firewalld
# systemctl enable firewalld

Use below command to add HTTP and HTTPS services in firewalld.
Then reload firewall to apply new changes.

# firewall-cmd --add-service={http,https} --permanent
# firewall-cmd --reload

Step 4: Testing

Run below command to test varnish.
Note: Replace osradar.localdomain.local with your own domain.

# curl -I osradar.localdomain.local

Congratulations! Varnish HTTP accelerator has been installed successfully and running as a reverse proxy for the Apache web server.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

-

Latest article

How to change the MAC address in Windows 10

Hello! How are you? Today we will see how to change the MAC address on a computer with Windows 10. In fact, it is...

How To Configure Slave BIND DNS Server On Ubuntu 20.04

In our previous guide we covered the setup of Master(Primary) DNS Server. Here we'll learn that how to configure slave bind dns server on...

Install Fossil on Linux – An alternative to Git

Hello, friends. In this post, we will talk about a serious alternative to Git. In a few words, we'll show you how to install...

How to backup and restore BCD in Windows 10

Hi! Boot Configuration Data (BCD) is a set of data where the system boot information is stored. In addition, from there the operating systems...

How To Install and Configure Master BIND DNS Server On Ubuntu 20.04

Today we are going to learn that how to install and configure Master BIND DNS server on Ubuntu 20.04. As you all know that...
x