Bobcares

HAProxy Varnish Apache | Installation

by | May 9, 2024

Let’s discuss the steps to set up HAProxy and Varnish on Apache servers. At Bobcares, with our Server Management Service, we can handle your issues.

Setting up HAProxy and Varnish on Apache Servers

We must run the following steps in order to set up HAProxy and Varnish on Apache:

1. Initially, set up HAProxy and Varnish on the server using the following command:

# apt-get install haproxy varnish

2. Then, download SSL certificates from Let’s Encrypt using the code:

haproxy varnish apache

3. Now, create combined chain + key PEM file.

# cat /etc/letsencrypt/live/mysite.com/fullchain.pem /etc/letsencrypt/live/mysite.com/privkey.pem > /etc/ssl/private/mysite.com.pem

4. Add frontend sections for ports 80 and 443 and a backend section pointing to varnish on port 8888 to the haproxy.cfg file. By uncommenting two lines in /etc/rsyslog.conf, we can enable UDP in rsyslog for haproxy logging:

# provides UDP syslog reception
module(load=”imudp”)
input(type=”imudp” port=”514″)

5. Now, restart rsyslog and HAProxy:

# service rsyslog restart
# service haproxy restart

6. Set varnish up to receive packets on port 8888. Systemd is used for service use in Ubuntu 16.04. In order to set the port that varnish will listen on, we must update two files:

/lib/systemd/system/varnish.service
/etc/default/varnish

7. In both cases, change the port to 8888 following the -a flag, stop the varnish service, reload the systemctl daemon, and then begin the varnish service again:

haproxy varnish apache

8. Set up nginx or Apache to listen on port 8080. Modify port 80 to 8080 for Apache in each virtual host and in /etc/apache2/ports.conf as well. An application configured as follows:

HAPROXY -> VARNISH -> APACHE (MOD_EVENT) -> PHP_FPM (REDIS + MYSQL)

[Want to learn more? Click here to reach us.]

Conclusion

The article explains the detailed steps from our Tech team to set up HAProxy and Varnish on Apache Servers.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.