OPNsense Forum

International Forums => French - Français => Topic started by: gfontaniere on May 09, 2020, 11:06:02 pm

Title: HAProxy : redirection vers multiples sites internes
Post by: gfontaniere on May 09, 2020, 11:06:02 pm
Ma version : OPNsense 20.1.6-i386

Bonsoir,

J'ai un problème avec HAProxy. Voici ce que je veux faire :

(https://i.ibb.co/dLH4xCz/haproxy.png) (https://ibb.co/Hx9T3wk)
 
J'arrive à rediriger un site en https vers un site interne, mais jamais plus d'un à la fois. J'ai testé chacun de mes renvois un à un et ils fonctionnent. Je pense avoir un souci avec les règles conditionnelles mais je ne vois pas d'où ça vient.

Voici ma configuration HAProxy :

Real Servers :
-------------
server1.example.com --> 192.168.1.1:5000
server2.example.com --> 192.168.1.1:801
server3.example.com --> 192.168.1.7:80

Backends Pool :
--------------
server1-backend --> HTTP (Layer7) --> Source IP Hash --> server1.example.com
server2-backend --> HTTP (Layer7) --> Source IP Hash --> server2.example.com
server3-backend --> HTTP (Layer7) --> Source IP Hash --> server3.example.com

Public Services :
----------------
server1-public --> Listen Addresses : 0.0.0.0:443 --> Default Backend Pool : server1-backend
                       --> SSL Offloadind ON --> Certificates : server1.example.com
                       --> Rules --> Select Rules : server1-rule

server2-public --> Listen Addresses : 0.0.0.0:443 --> Default Backend Pool : server2-backend
                       --> SSL Offloadind ON --> Certificates : server2.example.com
                       --> Rules --> Select Rules : server2-rule

server3-public --> Listen Addresses : 0.0.0.0:443 --> Default Backend Pool : server3-backend
                       --> SSL Offloadind ON --> Certificates : server3.example.com
                       --> Rules --> Select Rules : server3-rule

Conditions :
-----------
server1-condition --> Condition : Host matches
                            --> Parameters : server1.example.com

server2-condition --> Condition : Host matches
                            --> Parameters : server2.example.com

server3-condition --> Condition : Host matches
                            --> Parameters : server3.example.com

Rules :
------
server1-rule --> Optionnal condition
                    --> Test type : IF --> Select condition : server1-condition --> Logical operator : AND
                    --> HAProxy function --> Execute function : Use specified Backend Pool
                    --> Parameters --> Use backend pool : server1-backend


server2-rule --> Optionnal condition
                    --> Test type : IF --> Select condition : server2-condition --> Logical operator : AND
                    --> HAProxy function --> Execute function : Use specified Backend Pool
                    --> Parameters --> Use backend pool : server2-backend

server3-rule --> Optionnal condition
                    --> Test type : IF --> Select condition : server3-condition --> Logical operator : AND
                    --> HAProxy function --> Execute function : Use specified Backend Pool
                    --> Parameters --> Use backend pool : server3-backend

Toute aide serait la bienvenue.

Merci beaucoup.


Title: Re: HAProxy : redirection vers multiples sites internes
Post by: gfontaniere on May 10, 2020, 11:48:36 am
La solution est ici --> https://forum.opnsense.org/index.php?topic=17172.0
Title: Re: HAProxy : redirection vers multiples sites internes
Post by: dohko on May 13, 2020, 04:00:14 pm
J'ai une configuration similaire mais je n'ai mis en place d'un seul service publique (et non 3 comme mentionné).
Pour être précis, 1 pour l'activation du certificat Let's Encrypt et un 2° qui ne gère que le HTTPS et appelle tous les différents backends.

Ceci fonctionne très bien sans la solution du mapping donnée plus haut.
Title: Re: HAProxy : redirection vers multiples sites internes
Post by: gfontaniere on May 13, 2020, 05:12:45 pm
Effectivement, ca parait plus simple.
Au final  j'ai 4 certificats lets encrypt, 4 backends, 1 service public, 1 condition (qui précise le domaine.fr concerné) et 1 règle qui fait appel au fichier de mapping. Mais ça marche comme ça. Je ne touche plus à rien.
Merci pour la réponse.
Title: Re: HAProxy : redirection vers multiples sites internes
Post by: dohko on May 14, 2020, 06:22:44 pm
C'est testé egalement avec un fichier de mapping et ça fontionne.

Question pour toi, je vois que tu as fais des redirection vers ton Syno, est-ce que tu as pu essayé pour PhotoStation?
Title: Re: HAProxy : redirection vers multiples sites internes
Post by: gfontaniere on May 14, 2020, 07:09:38 pm
Désolé mais non. Je ne vois pas pourquoi ça ne marcherait pas. Pour info, en interne je redirige tout en http simple vers des ports différents sur le Syno comme indiqué sur le schéma.
Title: Re: HAProxy : redirection vers multiples sites internes
Post by: kagou on May 25, 2020, 09:36:45 am
Bonjour,
Est il possible que du coup tu nous refasses un descriptif de ce que tu as fait au final pour que cela fonctionne ?
J'ai le même souci que toi et je galère encore. Merci
Title: Re: HAProxy : redirection vers multiples sites internes
Post by: gfontaniere on May 25, 2020, 10:35:08 am
Je te remets pas tout mais ce qui m'a servi pour me dépatouiller...

(https://i.ibb.co/VCgvf0L/conditions01.png) (https://ibb.co/HPtr5LK)

(https://i.ibb.co/Nts3Rr4/conditions02.png) (https://ibb.co/djrcZth)

(https://i.ibb.co/wK8t7BC/rules01.png) (https://ibb.co/9qBPhc2)

(https://i.ibb.co/0KhjX6X/rules02.png) (https://ibb.co/xYJSsBs)

(https://i.ibb.co/7k74422/map-file01.png) (https://ibb.co/VwXmm22)

(https://i.ibb.co/wMLc8xS/map-file02.png) (https://ibb.co/TmTWJF4)

(https://i.ibb.co/s5qGH7w/publicservice01.png) (https://ibb.co/28dQNJt)

(https://i.ibb.co/1XRRc47/publicservice02.png) (https://ibb.co/C9VVLSm)

(https://i.ibb.co/MknzNH3/publicservice03.png) (https://ibb.co/zVs3fg0)