OPNsense Forum

International Forums => German - Deutsch => Topic started by: Moskito on April 07, 2021, 04:27:46 pm

Title: [gelöst] HAProxy + Lets encrypt und mehrere domains
Post by: Moskito on April 07, 2021, 04:27:46 pm
Mahlzeit!
Ich weiß, das Thema wurde schon mehrfach behandelt, aber irgendwie hab ich das noch nicht ganz erfasst.

Wenn ich eine Domain mit HAProxy und Lets encrypt konfiguriere, dann funktioniert das ganze wunderbar.
Jetzt versuche ich eine weitere Domain auf die selbe Art und Weise zu konfigurieren und dabei Scheiter ich kläglich.
Wenn ich die zweite Domain aktiviere, dann wird das Lets encrypt Zertifikat der zweiten Domain beim Aufruf der ersten ausgeliefert.... ::)
Ist es vielleicht gar nicht möglich mehre Domains so zu betreiben?
Gibt es irgendwo eine Anleitung für einen solchen Fall? ich hatte bisher leider nichts dazu gefunden... :-\

Hier mal meine HAProxy config:
Code: [Select]
#
# Automatically generated configuration.
# Do not edit this file manually.
#

global
    uid                         80
    gid                         80
    chroot                      /var/haproxy
    daemon
    stats                       socket /var/run/haproxy.socket group proxy mode 775 level admin
    nbproc                      1
    nbthread                    1
    tune.ssl.default-dh-param   2048
    spread-checks               2
    tune.chksize                16384
    tune.bufsize                16384
    tune.lua.maxmem             0
    log /var/run/log local0 info
    ssl-default-bind-options no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets ssl-min-ver TLSv1.2
    ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
    ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256

defaults
    log     global
    option redispatch -1
    timeout client 30s
    timeout connect 30s
    timeout server 30s
    retries 3
    default-server init-addr last,libc

# autogenerated entries for ACLs


# autogenerated entries for config in backends/frontends

# autogenerated entries for stats




# Frontend: nextcloud_80 ()
frontend nextcloud_80
    bind nextcloud.meinetolle.domain:80 name nextcloud.meinetolle.domain:80
    mode http
    option http-keep-alive
    # tuning options
    timeout client 30s

    # logging options
    # ACL: find_acme_challenge
    acl acl_606b40e6729f55.07300814 path_beg -i /.well-known/acme-challenge/
    # ACL: no_acme_challenge
    acl acl_606b42393e0889.34160247 path_beg -i /.well-known/acme-challenge/
    # ACL: SSLEstablished
    acl acl_606b4213be2157.54308208 req.ssl_ver gt 0

    # ACTION: redirect_acme_challenges
    use_backend acme_challenge_backend if acl_606b40e6729f55.07300814
    # ACTION: HTTPRedirect
    http-request redirect scheme https code 301 if !acl_606b42393e0889.34160247 !acl_606b4213be2157.54308208

# Frontend: nextcloud_443 ()
frontend nextcloud_443
    http-response set-header Strict-Transport-Security "max-age=15768000"
    bind nextcloud.meinetolle.domain:443 name nextcloud.meinetolle.domain:443 ssl no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets ssl-min-ver TLSv1.2 ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 crt-list /tmp/haproxy/ssl/606b4c0858aa63.89346434.certlist
    mode http
    option http-keep-alive
    # tuning options
    timeout client 30s

    # logging options
    # ACL: host_matches_nextcloud
    acl acl_606ac6de47ca46.73915082 hdr(host) -i nextcloud.meinetolle.domain

    # ACTION: Test_nextcloud
    use_backend nextcloud if acl_606ac6de47ca46.73915082

# Frontend: ttrss_80 ()
frontend ttrss_80
    bind ttrss.meinetolle.domain:80 name ttrss.meinetolle.domain:80
    mode http
    option http-keep-alive
    # tuning options
    timeout client 30s

    # logging options
    # ACL: find_acme_challenge
    acl acl_606b40e6729f55.07300814 path_beg -i /.well-known/acme-challenge/
    # ACL: no_acme_challenge
    acl acl_606b42393e0889.34160247 path_beg -i /.well-known/acme-challenge/
    # ACL: SSLEstablished
    acl acl_606b4213be2157.54308208 req.ssl_ver gt 0

    # ACTION: redirect_acme_challenges
    use_backend acme_challenge_backend if acl_606b40e6729f55.07300814
    # ACTION: HTTPRedirect
    http-request redirect scheme https code 301 if !acl_606b42393e0889.34160247 !acl_606b4213be2157.54308208

# Frontend: ttrss_443 ()
frontend ttrss_443
    http-response set-header Strict-Transport-Security "max-age=15768000"
    bind ttrss.meinetolle.domain:443 name ttrss.meinetolle.domain:443 ssl no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets ssl-min-ver TLSv1.2 ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256 crt-list /tmp/haproxy/ssl/606c89ebc63cb9.78334866.certlist
    mode http
    option http-keep-alive
    # tuning options
    timeout client 30s

    # logging options
    # ACL: host_matches_ttrss
    acl acl_606c8cd2e14a59.09882539 hdr(host) -i ttrss.meinetolle.domain

    # ACTION: Test_rss
    use_backend ttrss if acl_606c8cd2e14a59.09882539

# Backend: nextcloud ()
backend nextcloud
    # health checking is DISABLED
    mode http
    balance source
    # stickiness
    stick-table type ip size 50k expire 30m 
    stick on src
    # tuning options
    timeout connect 30s
    timeout server 30s
    http-reuse safe
    server nextcloud 192.168.2.57:80

# Backend: acme_challenge_backend (Added by Let's Encrypt plugin)
backend acme_challenge_backend
    # health checking is DISABLED
    mode http
    balance source
    # stickiness
    stick-table type ip size 50k expire 30m 
    stick on src
    # tuning options
    timeout connect 30s
    timeout server 30s
    http-reuse safe
    server acme_challenge_host 127.0.0.1:43580

# Backend: ttrss ()
backend ttrss
    # health checking is DISABLED
    mode http
    balance source
    # stickiness
    stick-table type ip size 50k expire 30m 
    stick on src
    # tuning options
    timeout connect 30s
    timeout server 30s
    http-reuse safe
    server ttrss 192.168.2.26:8280
Title: Re: HAProxy + Lets encrypt und mehrere domains
Post by: superwinni2 on April 07, 2021, 07:10:59 pm
Hast du auch im Frontend das zweite Zertifikat angegeben?
(Das sieht man leider in der Config Ausgabe nicht)

Gesendet von meinem OnePlus 8t mit Tapatalk

Title: Re: HAProxy + Lets encrypt und mehrere domains
Post by: Moskito on April 07, 2021, 07:29:45 pm
Ja, hab ich, was mir aber gerade komisch vorkommt, das Zertifikat für nextcloud.meinetolle.domain ist zweimal vorhanden! :o
Wie kommt sowas und wie bekomme ich das wieder weg?
Title: Re: HAProxy + Lets encrypt und mehrere domains
Post by: superwinni2 on April 07, 2021, 07:38:29 pm
Ich glaube hier liegt ein typischer Anfänger Fehler vor... Sind Nextcloud und dein ttrss auf der gleichen öffentlichen IP?
Falls ja so muss hierfür ein gemeinsamer Öffentlicher Dienst angelegt werden und mithilfe von Regeln das Backend unterschieden werden.

Gesendet von meinem OnePlus 8t mit Tapatalk

Title: Re: HAProxy + Lets encrypt und mehrere domains
Post by: Moskito on April 08, 2021, 09:10:10 am
Das war es!
Ich habe jetzt einen gemeinsamen öffentlichen Dienst eingerichtet und dann per Regel aufgesplittet.

Jetzt ist mir auch klar, warum in den meisten HowTos als Listen Address 0.0.0.0:80 bzw. 0.0.0.0:443 steht.
Allerdings kann ich die nicht nehmen, da sonst HAProxy nicht mehr startet, da auf 0.0.0.0:80 schon irgend ein Dienst lauschen würde. :-\

Also gleich noch eine Anschlussfrage, wie kriege ich raus, was auf 0.0.0.0:80 bzw. 0.0.0.0:443 lauscht? ::)
Title: Re: HAProxy + Lets encrypt und mehrere domains
Post by: superwinni2 on April 08, 2021, 01:33:39 pm
ja wenn man HAProxy nur auf einem Debian Host oder ähnliches laufen lässt, dann kann man 0.0.0.0:80/443 nehmen... Da aber unter anderem die FW-GUI bereits auf beide Ports (auf dem LAN Interface) lauscht ist dies nicht möglich.


Ich empfehle unter "System -> Settings -> Administration" die "Listen Interfaces" anzupassen auf das was benötigt wird. (WAN eben meistens nicht.)
Dann im HAProxy auf die WAN Adressen mit Port 80 und 443 lauschen lassen.
Title: Re: HAProxy + Lets encrypt und mehrere domains
Post by: Moskito on April 09, 2021, 10:44:02 pm
Bingo!

Das war es!

Vielen Dank nochmal!