How to install Haproxy and Traefik on Proxmox VM with CentOS 7

RomanAcademy
4 min readFeb 2, 2023

--

https://metarevolution.world/

#HAProxy or #Traefik High Availability Proxy is an open source TCP and HTTP load balancer and proxy server software. HAProxy has been written by Willy Tarreau in C, it supports SSL, compressions, keep-alive, custom log formats and header rewriting. HAProxy is a fast and lightweight proxy server and load balancer with a small memory footprint and low CPU usage. It is used by large sites like Github, StackOverflow, Reddit, Tumblr, Twitter and others. It has become the most popular software load balancer and proxy server in the past years.

Lets see small analyze what's differences between this both apps

HAProxy vs Traefik: What are the differences?

Developers describe HAProxy as “The Reliable, High Performance TCP/HTTP Load Balancer”. HAProxy (High Availability Proxy) is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. On the other hand, Traefik is detailed as “Load Balancer for Microservices”. Træfɪk is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. It supports several backends (Docker, Swarm, Mesos/Marathon, Kubernetes, Consul, Etcd, Zookeeper, BoltDB, Rest API, file…) to manage its configuration automatically and dynamically.

HAProxy and Traefik can be categorized as “Load Balancer / Reverse Proxy” tools.

“Load balancer” is the primary reason why developers consider HAProxy over the competitors, whereas “Kubernetes integration” was stated as the key factor in picking Traefik.

Traefik is an open source tool with 23K GitHub stars and 2.36K GitHub forks. Here’s a link to Traefik’s open source repository on GitHub.

According to the StackShare community, HAProxy has a broader approval, being mentioned in 452 company stacks & 205 developers stacks; compared to Traefik, which is listed in 46 company stacks and 17 developer stacks.

Installation Guide

Preparation:

Before you start installing HAProxy and Traefik on your Proxmox Virtual Machine (VM) with CentOS 7, there are a few pre-setting up tasks that you need to complete:

  1. Create a Proxmox VM with CentOS 7 installed.
  2. Assign a static IP address to the VM.
  3. Login to the VM as the root user or a user with root privileges.
  4. Make sure that the system is up to date by running sudo yum update -y.
  5. Install any required dependencies, such as Docker.
  6. Configure the firewall to allow access to the required ports for HAProxy and Traefik.
  7. Create a directory for the Traefik configuration file, if it does not already exist.

By completing these pre-setting up tasks, you will ensure that your environment is ready for the installation and configuration of HAProxy and Traefik.

https://istore.airriseinc.com/

HAProxy Installation:

  1. Update the system: sudo yum update -y
  2. Install HAProxy: sudo yum install haproxy -y
  3. Start the HAProxy service: sudo systemctl start haproxy
  4. Enable the HAProxy service to start at boot: sudo systemctl enable haproxy
  5. Configure HAProxy by editing the configuration file: sudo nano /etc/haproxy/haproxy.cfg
  6. In the configuration file, specify the backend servers and listening ports. For example:
global
daemon
maxconn 256

defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms

frontend http-in
bind *:80
default_backend servers

backend servers
server server1 192.168.1.100:80 check
server server2 192.168.1.101:80 check
  1. Save and close the configuration file.
  2. Restart the HAProxy service to apply the changes: sudo systemctl restart haproxy
https://istore.airriseinc.com/

Traefik Installation:

  1. Update the system: sudo yum update -y
  2. Install Docker: sudo yum install -y docker
  3. Start Docker service: sudo systemctl start docker
  4. Enable Docker service to start at boot: sudo systemctl enable docker
  5. Create a Traefik configuration file: sudo nano /etc/traefik.toml
  6. In the configuration file, specify the entrypoints, backend servers, and the dashboard access credentials. For example:
defaultEntryPoints = ["http"]

[entryPoints]
[entryPoints.http]
address = ":80"

[api]
entryPoint = "traefik"
dashboard = true

[providers.docker]
endpoint = "unix:///var/run/docker.sock"
exposedByDefault = false

[accessLog]

[web]
address = ":8080"
username = "admin"
password = "password"
  1. Save and close the configuration file.
  2. Run Traefik in a Docker container:
sudo docker run -d \
--name traefik \
--restart always \
-p 80:80 \
-p 8080:8080 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /etc/traefik.toml:/etc/traefik/traefik.toml \
traefik
  1. Access the Traefik dashboard by navigating to http://<IP_Address>:8080 in your web browser.

Note: Replace <IP_Address> with the IP address of your Proxmox VM.

This should give you a basic setup of HAProxy and Traefik on a CentOS 7 Proxmox VM. You can further configure and customize these tools based on your specific needs and requirements.

We are Work for you Learning

Thank you for Reading is make you better !!!!

Our Sponsor Electronics Online Store with Best prices: https://istore.airriseinc.com/ — — https://metarevolution.world/

https://istore.airriseinc.com/

--

--

RomanAcademy
RomanAcademy

Written by RomanAcademy

If software and web development are something you’re interested in, you’ll find a lot of helpful information on this channel.

No responses yet