Info::proxy/proxies pour ModBus tcp

De wiki_pcwiki2
Aller à la navigationAller à la recherche

KEYWORDS: PROXY, PROXIES, MODBUS

Le 15/05/2025:
Puisje avoir les configs pour haproxy, redir et socat ?
ChatGPT a dit :

Voici les configurations complètes pour exposer tes deux adresses Modbus TCP (192.168.1.252:1485 et 192.168.1.253:2485) via :
   🔁 HAProxy
   🔁 socat
🥇 HAProxy (robuste, système de production)
📦 Installation :
apt install haproxy

🗂️ Fichier de configuration /etc/haproxy/haproxy.cfg
Ajoute à la fin (ou adapte) :
global
   log /dev/log local0
   maxconn 2000
   daemon

defaults
   mode tcp
   timeout connect 5s
   timeout client  30s
   timeout server  30s

frontend modbus1
   # bind *:1485
   bind 127.0.0.1:1485
   default_backend modbus1_backend

backend modbus1_backend
   server modbus1 192.168.1.252:1485 check

frontend modbus2
   # bind *:2485
   bind 127.0.0.1:2485
   default_backend modbus2_backend
backend modbus2_backend
   server modbus2 192.168.1.253:2485 check

🚀 Redémarrage :
systemctl restart haproxy
 🥉 socat (puissant, léger)
📦 Installation :
apt install socat

🔁 Commandes simples :
# Expose localement le port 1485 pour accéder à 192.168.1.252:1485
socat TCP-LISTEN:1485,reuseaddr,fork TCP:192.168.1.252:1485 &

# Expose localement le port 2485 pour accéder à 192.168.1.253:2485
socat TCP-LISTEN:2485,reuseaddr,fork TCP:192.168.1.253:2485 &