« Haproxy : Reverse Proxy https » : différence entre les versions

De www.yakakliker.org
Aucun résumé des modifications
Aucun résumé des modifications
 
(8 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
=== Approche 1 : http/https to http ===
=== Approche 1 ===
Avec cette approche, la communication se fait en http avec le backend (serveur web de destination) et en http où https avec les clients.
Avec cette approche, la communication se fait en http avec le backend (serveur web de destination) et en http où https avec les clients.


Ligne 33 : Ligne 33 :
</syntaxhighlight>
</syntaxhighlight>


=== Approche 2 : https (uniquement) to http ===
=== Approche 2 ===
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
frontend yakakliker
frontend yakakliker
     bind *:80
     bind *:80
     bind *:443 ssl crt /etc/haproxy/cert/www.yakakliker.org.pem
     bind *:443 ssl crt /etc/haproxy/cert/www.yakakliker.org.pem name www.yakakliker.org
 
    filter cache mycache
    http-request cache-use mycache
    http-response cache-store mycache
 
     mode http
     mode http
     option httplog
     option httplog
Ligne 44 : Ligne 49 :
     use_backend backend1 if yaka_acl
     use_backend backend1 if yaka_acl


 
backend backend1
backend backend1
    balance roundrobin
     mode http
     mode http
     balance source
 
     filter cache mycache
    http-request cache-use mycache
    http-response cache-store mycache
 
 
     option httpchk
     option httpchk
    http-check expect ! rstatus ^5
    default-server inter 3s fall 3 rise 2
     option forwardfor except 127.0.0.1
     option forwardfor except 127.0.0.1
     http-request add-header X-Forwarded-Proto https if { ssl_fc }
     http-request add-header X-Forwarded-Proto https if { ssl_fc }
     server web-server1  Adresse_IP:80 maxconn 32
     server web-server1  192.168.1.100:80 check
    server web-server2  192.168.2.100:80 check
 
 
</syntaxhighlight>


=== Test de la configuration ===
<syntaxhighlight lang="bash">
haproxy -f /etc/haproxy/haproxy.cfg -c
</syntaxhighlight>
</syntaxhighlight>


Ligne 59 : Ligne 79 :


https://www.haproxy.com/blog/redirect-http-to-https-with-haproxy#redirect-to-https
https://www.haproxy.com/blog/redirect-http-to-https-with-haproxy#redirect-to-https
[[Haproxy : Unable to load SSL private key from PEM file]]
https://gist.github.com/urodoz/d7796cec6d47566439ba3d8ecce962f1
[[Catégorie:Haproxy]]
[[Catégorie:Haproxy]]
[[Catégorie:SSL]]
[[Catégorie:SSL]]
‎<html>
<script src='https://storage.ko-fi.com/cdn/scripts/overlay-widget.js'></script>
<script>
  kofiWidgetOverlay.draw('yakakliker', {
    'type': 'floating-chat',
    'floating-chat.donateButton.text': 'Café',
    'floating-chat.donateButton.background-color': '#00b9fe',
    'floating-chat.donateButton.text-color': '#fff'
  });
</script>
‎</html>
‎<html>
<a href="https://www.compteurdevisite.com" title="compteur web gratuit sans pub"><img src="https://counter6.optistats.ovh/private/compteurdevisite.php?c=b4epghealnwlf7wuq7gn3ygll9aywrfx" border="0" title="compteur web gratuit sans pub" alt="compteur web gratuit sans pub"></a>
‎</html>

Dernière version du 17 février 2025 à 14:37

Approche 1

Avec cette approche, la communication se fait en http avec le backend (serveur web de destination) et en http où https avec les clients.

Les certificats sont hébergés uniquement sur HAproxy

frontend yakakliker
    bind *:80
    mode http
    option httplog
    acl yaka_acl  hdr(host)   www.yakakliker.org
    use_backend backend1 if yaka_acl



frontend yakakliker_443
    bind *:443 ssl crt /etc/haproxy/cert/www.yakakliker.org.pem
    mode http
    option httplog
    acl yaka_acl  hdr(host)   www.yakakliker.org

    redirect scheme https code 301 if !{ ssl_fc }
    use_backend backend1 if yaka_acl



backend backend1
    mode http
    balance source
    option httpchk
    option forwardfor except 127.0.0.1
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    server web-server1  Adresse_IP:80 maxconn 32

Approche 2

frontend yakakliker
    bind *:80
    bind *:443 ssl crt /etc/haproxy/cert/www.yakakliker.org.pem name www.yakakliker.org

    filter cache mycache
    http-request cache-use mycache
    http-response cache-store mycache

    mode http
    option httplog
    acl yaka_acl  hdr(host)   www.yakakliker.org
    http-request redirect scheme https code 301 unless { ssl_fc }
    use_backend backend1 if yaka_acl

 
backend backend1
    balance roundrobin
    mode http

    filter cache mycache
    http-request cache-use mycache
    http-response cache-store mycache


    option httpchk
    http-check expect ! rstatus ^5
    default-server inter 3s fall 3 rise 2
    option forwardfor except 127.0.0.1
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    server web-server1  192.168.1.100:80 check
    server web-server2  192.168.2.100:80 check

Test de la configuration

 haproxy -f /etc/haproxy/haproxy.cfg -c

Lien

https://wiki.maxcorp.org/configurer-un-reverse-proxy-avec-haproxy-http-https/

https://www.haproxy.com/blog/redirect-http-to-https-with-haproxy#redirect-to-https

Haproxy : Unable to load SSL private key from PEM file

https://gist.github.com/urodoz/d7796cec6d47566439ba3d8ecce962f1

compteur web gratuit sans pub