MODOP – Cluster IPFS RAID1 – déploiement Site Web en mode H.A – Partie 6

1. Création d’un mini site pour la démo

Structure

spongebob-site/
├── index.html
├── about.html
├── gallery.html
├── css/
│ └── style.css
├── js/
│ └── script.js
└── images/
├── spongebob1.jpg
├── patrick.png
└── bikini-bottom.jpg
[root@node-ipfsl home]# mkdir -p spongebob-site/{css,js,images}

Page index.html

[root@node-ipfsl home]# cd spongebob-site/
[root@node-ipfsl spongebob-site]# vi index.html

<!DOCTYPE html>
<html lang="fr">
<head>
 <meta charset="UTF-8">
 <title>Bienvenue à Bikini Bottom</title>
 <link rel="stylesheet" href="css/style.css">
 <script src="js/script.js" defer></script>
</head>

<body>
 <header>
 <h1>Bienvenue dans l'univers de SpongeBob !</h1>
 <nav>
 <a href="index.html">Accueil</a>
 <a href="about.html">À propos</a>
 <a href="gallery.html">Galerie</a>
 </nav>
 </header>

 <main>
 <img src="images/spongebob1.jpg" alt="SpongeBob souriant" width="300">
 <p>Explore le monde sous-marin de Bikini Bottom avec SpongeBob et ses amis !</p>
 </main>

 <footer>
 <p>&copy; 2025 Création par Chris@house.cpb</p>
 </footer>
</body>
</html>

Page about.html

[root@node-ipfsl spongebob-site]# vi about.html

<!DOCTYPE html>
<html lang="fr">
<head>
 <meta charset="UTF-8">
 <title>À propos</title>
 <link rel="stylesheet" href="css/style.css">
 <script src="js/script.js" defer></script>
</head>

<body>
 <header>
 <h1>À propos de ce site</h1>
 <nav>
 <a href="index.html">Accueil</a>
 <a href="about.html">À propos</a>
 <a href="gallery.html">Galerie</a>
 </nav>
 </header>

 <main>
 <p>Ce site est une célébration créative de l’univers de SpongeBob et inspirée de Bikini Bottom.</p>
 <p>Créé par Christian, passionné de web et de dessins animés.</p>
 </main>

 <footer>
 <p>&copy; 2025 Création par Chris@house.cpb </p>
 </footer>
</body>
</html>

Page gallery.html

[root@node-ipfsl spongebob-site]# vi gallery.html

<!DOCTYPE html>
<html lang="fr">
<head>
 <meta charset="UTF-8">
 <title>Galerie</title>
 <link rel="stylesheet" href="css/style.css">
 <script src="js/script.js" defer></script>
</head>

<body>
 <header>
 <h1>Galerie de Bikini Bottom</h1>
 <nav>
 <a href="index.html">Accueil</a>
 <a href="about.html">À propos</a>
 <a href="gallery.html">Galerie</a>
 </nav>
 </header>

 <main>
 <section class="gallery">
 <img src="images/spongebob1.jpg" alt="SpongeBob" width="200">
 <img src="images/patrick.png" alt="Patrick" width="200">
 <img src="images/bikini-bottom.jpg" alt="Bikini Bottom" width="200">
 </section>
 </main>

 <footer>
 <p>&copy; 2025 Création par Chris@house.cpb</p>
 </footer>
</body>
</html>

Page de style css/style.css

[root@node-ipfsl spongebob-site]# vi css/style.css

/* Style général */
body {
 font-family: 'Comic Sans MS', cursive, sans-serif;
 background: linear-gradient(to bottom, #a0eaff, #f0ffff);
 color: #333;
 margin: 0;
 padding: 0;
}

/* En-tête */

header {
 background-color: #ffe600;
 padding: 20px;
 text-align: center;
 border-bottom: 5px solid #ff9900;
}

header h1 {
 margin: 0;
 font-size: 2.5em;
 color: #0055aa;
}

/* Navigation */

nav {
 margin-top: 10px;
}

nav a {
 margin: 0 15px;
 text-decoration: none;
 color: #0077cc;
 font-weight: bold;
}

nav a:hover {
 color: #ff6600;
}

/* Contenu principal */
main {
 padding: 20px;
 text-align: center;
}

/* Galerie */
.gallery {
 display: flex;
 justify-content: center;
 gap: 20px;
 flex-wrap: wrap;
 margin-top: 20px;
}

.gallery img {
 border: 3px solid #ffcc00;
 border-radius: 10px;
 transition: transform 0.3s;
}

.gallery img:hover {
 transform: scale(1.1);
}

/* Pied de page */
footer {
 background-color: #ffe600;
 text-align: center;
 padding: 10px;
 border-top: 5px solid #ff9900;
 position: relative;
 bottom: 0;
 width: 100%;
}

Page de script : js/script.js

[root@node-ipfsl spongebob-site]# vi js/script.js

// message de bienvenue
window.addEventListener('DOMContentLoaded', () => {
 alert("Bienvenue à Bikini Bottom ! 🧽🌊");
});

Images

[root@node-ipfsl spongebob-site]# cd images/
  • images/spongebob1.jpg
  • images/patrick.png
  • images/bikini-bottom.jpg
[root@node-ipfsl images]# wget https://i.pinimg.com/736x/b5/9d/7b/b59d7ba1520c46c32fe92b5b6c8b0097--luna-ukulele-ukulele-art.jpg spongebob1.jpg && mv mvb59d7ba1520c46c32fe92b5b6c8b0097--luna-ukulele-ukulele-art.jpg spongebob1.jpg

[root@node-ipfsl images]# wget https://www.pngplay.com/wp-content/uploads/14/Spongebob-And-Patrick-No-Background.png && mv Spongebob-And-Patrick-No-Background.png patrick.png

[root@node-ipfsl images]# wget https://i.pinimg.com/originals/6b/1c/a4/6b1ca4fb540aa01411ba69fea7b4fad4.jpg && mv 6b1ca4fb540aa01411ba69fea7b4fad4.jpg bikini-bottom.jpg

[root@node-ipfsl images]# cd ../..

[root@node-ipfsl home]# du -a spongebob-site/

2. Ajout du site Web sur le Cluster IPFS de 6 peers et 1 leader

[root@node-ipfsl home]# ipfs add -r spongebob-site/

[root@node-ipfsl home]# ipfs add -r spongebob-site/
added QmQU7A1iWFGXR8JuJwpudhGs59BKwSzt3AKFawUkDSahQZ spongebob-site/about.html
added QmTwd45sjBJChyJiL9GRYJ8QrTFfSmJXGmCiBhKNfxcoeC spongebob-site/css/style.css
added QmUW3ZxZqygWK9UnrZerYCp55WJsqezr9ZM3Fu76RaUe5t spongebob-site/gallery.html
added QmYptE7uFvfUBX7HzXS7nFTNWfKBTKWqabMx9R5q8FWptJ spongebob-site/images/bikini-bottom.jpg
added QmRnakAuccrg1YYaQLJEGJgdkpR1d7HaANcsHXUPJkYmw9 spongebob-site/images/patrick.png
added QmTmGcEFvicbREu8JyvVYYZFHK5ft2PiPtxcm4KPTnPvmH spongebob-site/images/spongebob1.jpg
added QmR1Ur6NYPCoiQgJ1MWUtgskkeQpDrML9CBxCJs9nDPvBK spongebob-site/index.html
added QmPvGFKhoUvUN6nVd9DerM9Ty1hPrKL4cdvBzwa159U9Bq spongebob-site/js/script.js
added QmcBDd4GFd6BvRGa8svMnMQwWugQifqUN5mJD7dGCypMCB spongebob-site/css
added Qmdasvvo4i1fG66g6fQwBf7qXEMuDPhvMaAvRGuj2h1Dah spongebob-site/images
added QmT5KvjXxmj8fu18xjtiwh3Ek6ZKSWt6B2hymtUGdx89yy spongebob-site/js
added QmSaVM6BoUmyPuiEs6FGo5PH9eYDReHAYubb9sZkcCJcrk spongebob-site

3 . Check du site spongebob mode P2P

Check site spongebob sur leader

  • http://192.168.1.70:8080/ipfs/QmSaVM6BoUmyPuiEs6FGo5PH9eYDReHAYubb9sZkcCJcrk

Check réplication des données site spongebob sur peer n°1 & peer n°2

Check réplication des données site spongebob sur peer n°3 & peer n°4

Check réplication des données site spongebob sur peer n°5 & peer n°6

4. Installaton d’un cluster H.A Proxy

Inventaire des deux machines du cluster H.A proxy

Hostname
  • Node-ipfsh1 : IP = 192.168.1.77
  • Node-ipfsh2 : IP = 192.168.1.78

Installation des prérequis (2 nœuds)

[root@node-ipfshx ~]# dnf -y update

Installation des middlewares (2 nœuds ) 

[root@node-ipfshx ~]# dnf install dnf-utils epel-release net-tools nmap curl wget tar -y

Synchroniser DateTime sur le fuseau de PARIS (2 nœuds) 

[root@node-ipfsx ~]# timedatectl set-timezone Europe/Paris

Désactiver SELinux (2 nœuds) 

[root@node-ipfshx ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
[root@node-ipfshx ~]# setenforce 0

5. Règle Firewalld pour Keepalived (VRRP) (2 nœuds) 

[root@node-ipfshx ~]# firewall-cmd --add-rich-rule='rule protocol value="vrrp" accept' --permanent
[root@node-ipfshx ~]# firewall-cmd --remove-service={cockpit,dhcpv6-client} --permanent
[root@node-ipfshx ~]# firewall-cmd --reload

6. Installation du « heartbeat » keepAlive (2 nœuds) 

[root@node-ipfshx ~]# dnf install keepalived ipvsadm –y

Modules IPVS

[root@node-ipfshx ~]# lsmod |grep ip_vs
ip_vs 237568 0
nf_conntrack 229376 3 nf_nat,nft_ct,ip_vs
nf_defrag_ipv6 24576 2 nf_conntrack,ip_vs
libcrc32c 12288 5 nf_conntrack,nf_nat,nf_tables,xfs,ip_vs

Modules à charger

[root@node-ipfshx ~]# modprobe ip_vs
[root@node-ipfshx ~]# modprobe ip_vs_rr
[root@node-ipfshx ~]# modprobe ip_vs_wrr
[root@node-ipfshx ~]# modprobe ip_vs_sh
[root@node-ipfshx ~]# modprobe nf_conntrack

Chargement automatique au démarrage

[root@node-ipfshx ~]# echo ip_vs >> /etc/modules-load.d/ipvs.conf
[root@node-ipfshx ~]# echo ip_vs_rr >> /etc/modules-load.d/ipvs.conf
[root@node-ipfshx ~]# echo ip_vs_wrr >> /etc/modules-load.d/ipvs.conf
[root@node-ipfshx ~]# echo ip_vs_sh >> /etc/modules-load.d/ipvs.conf
[root@node-ipfshx ~]# echo nf_conntrack >> /etc/modules-load.d/ipvs.conf

[root@node-ipfshx ~]# systemctl restart systemd-modules-load.service

Configuration KeepAlive

Node-ipfsh1

[root@node-ipfsh1 ~]# mv /etc/keepalived/keepalived.conf{,-old}
[root@node-ipfsh1 ~]# vi /etc/keepalived/keepalived.conf

! /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
 notification_email {
 chris@house.cpb
 }
 notification_email_from chris@house.cpb
 smtp_server localhost
 smtp_connect_timeout 30
 }

vrrp_instance VI_1 {
 state MASTER
 interface ens18
 virtual_router_id 100
priority 200
 authentication {
 auth_type PASS
 auth_pass EYZTE865433021
 }

 virtual_ipaddress {
192.168.1.79/24 dev ens18
 }
}

Node-ipfsh2

[root@node-ipfsh2 ~]# mv /etc/keepalived/keepalived.conf{,-old}
[root@node-ipfsh2 ~]# vi /etc/keepalived/keepalived.conf

! /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
chris@house.cpb
}
 notification_email_from chris@house.cpb
 smtp_server localhost
 smtp_connect_timeout 30
}

vrrp_instance VI_1 {
 state BACKUP
 interface ens18
 virtual_router_id 100
 priority 199
authentication {
 auth_type PASS
 auth_pass EYZTE865433021
}

virtual_ipaddress {
192.168.1.79/24 dev ens18
}
}

Prérequis KeepAlive

[root@node-ipfshx ~]# echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
[root@node-ipfshx ~]# sysctl -p
net.ipv4.ip_nonlocal_bind = 1

Lancement du service KeepAlived

[root@node-ipfshx ~]# systemctl enable keepalived
Created symlink /etc/systemd/system/multi-user.target.wants/keepalived.service → /usr/lib/systemd/system/keepalived.service.

[root@node-ipfshx ~]# systemctl start keepalived

Node-ipfsh1

[root@node-ipfsh1 ~]# systemctl status keepalived

[root@node-ipfsh1 ~]# ip a show ens18

Node-ipfsh2

[root@node-ipfsh2 ~]# systemctl status keepalived

[root@node-ipfsh2 ~]# ip a show ens18

7. Installation HaProxy (2 nœuds )

Installation du packet haproxy

[root@node-ipfshx ~]# dnf install -y haproxy

Configuration des services Front et backend

[root@node-ipfshx ~]# mv /etc/haproxy/haproxy.cfg{,-old}
[root@node-ipfshx ~]# vi /etc/haproxy/haproxy.cfg

global
 log /dev/log local0
 log /dev/log local1 notice
 daemon
 maxconn 2048

defaults
 log global
 mode http
 option httplog
 option dontlognull
 retries 2
 timeout client 30m
 timeout connect 4s
 timeout server 30m
 timeout check 5s

listen stats
mode http
bind *:1234
stats enable
stats uri /status
stats refresh 2s
stats auth chris:Chris
stats admin if TRUE

# Frontend pour le Site Web IPFS (port 80 → 8080)
frontend ipfs_WebSite
 bind *:80
 mode http
 default_backend ipfs_WebSite_backend

# Backend vers les serveurs IPFS sur port 8080
backend ipfs_WebSite_backend
 mode http
 balance roundrobin
 option httpchk GET /ipfs/QmSaVM6BoUmyPuiEs6FGo5PH9eYDReHAYubb9sZkcCJcrk
 server ipfsl 192.168.1.70:8080 check inter 2s
 server ipfsp1 192.168.1.71:8080 check inter 2s
 server ipfsp2 192.168.1.72:8080 check inter 2s
 server ipfsp3 192.168.1.73:8080 check inter 2s
 server ipfsp4 192.168.1.74:8080 check inter 2s
 server ipfsp5 192.168.1.75:8080 check inter 2s
 server ipfsp6 192.168.1.76:8080 check inter 2s

#Frontend pour l’API IPFS (port 5001 → 5001)
frontend ipfs_api
 bind *:5001
 mode http
 default_backend ipfs_api_backend

# Backend vers les serveurs IPFS sur port 5001
backend ipfs_api_backend
 mode http
 balance roundrobin
 option httpchk GET /webui 
 server ipfsl 192.168.1.70:5001 check inter 2s
 server ipfsp1 192.168.1.71:5001 check inter 2s
 server ipfsp2 192.168.1.72:5001 check inter 2s
 server ipfsp3 192.168.1.73:5001 check inter 2s
 server ipfsp4 192.168.1.74:5001 check inter 2s
 server ipfsp5 192.168.1.75:5001 check inter 2s
 server ipfsp6 192.168.1.76:5001 check inter 2s

Vérification de la syntax du fichier de configuration

[root@node-ipfshx ~]# haproxy -c -V -f /etc/haproxy/haproxy.cfg
Configuration file is valid

Lancement du service HAproxy

[root@node-ipfshx ~]# systemctl enable haproxy
Created symlink /etc/systemd/system/multi-user.target.wants/haproxy.service → /usr/lib/systemd/system/haproxy.service.
[root@node-ipfsh1 log]# systemctl status haproxy

8. Règle Firewalld pour HAproxy

[root@node-ipfshx ~]# firewall-cmd --add-port={1234,80,5001}/tcp –permanent
[root@node-ipfshx ~]# firewall-cmd --reload
[root@node-ipfshx ~]# firewall-cmd --list-all

9. Check HaProxy

Crédenciales définis dans le fichier de configuration HAproxy (stats auth chris:Chris)

Check UP du serveur WebSite spongebob

Check UP des API des peers IPFS

Check d’accès au site Spongebob répliqué sur les 6 peers et leader

Views: 0

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *