
UPDATE UNTEN
________________Ich habe mich entschieden, HAProxy als Reverse-Proxy für SharePoint-Sites zu verwenden, und ohne SSL funktioniert alles einwandfrei, aber mit SSL kann ich haproxy.service nicht starten. Ich habe es mit vielen Konfigurationen versucht, aber ich komme nicht dahinter ...
Versuch, den Dienst zu starten:
$ sudo systemctl start haproxy.service
Job for haproxy.service failed because the control process exited with error code.
See "systemctl status haproxy.service" and "journalctl -xe" for details.
Status des haproxy.service:
$ sudo systemctl status haproxy.service
haproxy.service - HAProxy Load Balancer
Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since date CEST;
Docs: man:haproxy(1)
file:/usr/share/doc/haproxy/configuration.txt.gz
Process: ExecStart=/usr/sbin/haproxy-systemd-wrapper -f $CONFIG -p $PIDFILE $EXTRAOPTS (code=exited, status=0/SUCCESS)
Process: ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=1/FAILURE)
Main PID: (code=exited, status=0/SUCCESS)
systemd[1]: haproxy.service: Failed with result 'exit-code'.
systemd[1]: haproxy.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped HAProxy Load Balancer.
systemd[1]: haproxy.service: Start request repeated too quickly.
systemd[1]: Failed to start HAProxy Load Balancer.
systemd[1]: haproxy.service: Unit entered failed state.
systemd[1]: haproxy.service: Failed with result 'exit-code'.
systemd[1]: haproxy.service: Start request repeated too quickly.
systemd[1]: Failed to start HAProxy Load Balancer.
systemd[1]: haproxy.service: Failed with result 'exit-code'.
Überprüfen von Problemen mit der Konfigurationsdatei:
$ sudo haproxy -c -f haproxy.cfg
Enter PEM pass phrase:
[ALERT]: parsing [haproxy.cfg:31] : 'bind *:443' : unable to load SSL private key from PEM file './cert.pem'.
[ALERT]: Error(s) found in configuration file : haproxy.cfg
[ALERT]: Proxy 'http_id': no SSL certificate specified for bind '*:443' at [haproxy.cfg:31] (use 'crt').
[ALERT]: Fatal errors found in configuration.
HAProxy -vv:
$ sudo haproxy -vv
HA-Proxy version 1.7.5-2
Encrypted password support via crypt(3): yes
Built with zlib version : 1.2.8
Running on zlib version : 1.2.8
Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")
Built with OpenSSL version : OpenSSL 1.1.0e
Running on OpenSSL version : OpenSSL 1.1.0f
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports prefer-server-ciphers : yes
Built with PCRE version : 8.39
Running on PCRE version : 8.39
PCRE library supports JIT : no (USE_PCRE_JIT not set)
Built with Lua version : Lua 5.3.3
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Built with network namespace support
Available polling systems :
epoll : pref=300, test result OK
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 3 (3 usable), will use epoll.
Available filters :
[COMP] compression
[TRACE] trace
[SPOE] spoe
Protokolle:
haproxy: [ALERT]: parsing [/etc/haproxy/haproxy.cfg:31] : 'bind *:443' : unable to load SSL certificate file './cert.pem' file does not exist.
haproxy: [ALERT]: Error(s) found in configuration file : /etc/haproxy/.cfg
haproxy: [ALERT]: Proxy 'http_id': no SSL certificate specified for bind '*:443' at [/etc/haproxy/haproxy.cfg:31] (use 'crt').
haproxy: [ALERT]: Fatal errors found in configuration.
Ich verwende dasselbe Zertifikat (aber geteilt: Zertifikat, Schlüssel, Kette) für nginx auf einem anderen Server und es funktioniert. Ich habe dieses für HAProxy mit cat cert.crt priv.key certchain.crt > cert.pem
einem Befehl erstellt und es in unterschiedlicher Reihenfolge versucht, aber der Fehler ist derselbe. Außerdem haproxy -c -f haproxy.cfg
fragt der Server mit dem Befehl nach der Passphrase, also denke ich, dass das Zertifikat in Ordnung ist (vielleicht irre ich mich) und etwas mit der Konfigurationsdatei nicht stimmt. Vielen Dank für Ihre Zeit und Hilfe.
Meine haproxy.cfg:
global
tune.ssl.default-dh-param 2048
maxconn 4096
user haproxy
group haproxy
daemon
#ssl-server-verify none
defaults
mode http
option forwardfor
log 127.0.0.1 local0 notice
maxconn 2000
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
backend sharepoint
mode http
#balance roundrobin
option redispatch
cookie SERVERID insert nocache
server spsrv xxx.xxx.xxx.xxx:80
frontend http_id
#bind *:80
bind *:443 ssl crt ./cert.pem
mode http
reqadd X-Forwarded-Proto:\ https
acl hosts_sharepoint hdr_end(host) -i intranet.sharepoint.com:443
use_backend sharepoint if hosts_sharepoint
default_backend sharepoint
ERSTES UPDATE
Ich habe es mit Pass-Through versucht und jetzt fragt SharePoint nach Anmeldeinformationen (nachdem die IIS-Rolle deaktiviert wurde) auf Port 80 und leitet dann mit dem Fehler „504 Gateway Time-out“ auf https um. Dies ist meine aktuelle haproxy.cfg:
global
maxconn 4096
user haproxy
group haproxy
daemon
defaults
mode tcp
log 127.0.0.1 local0 notice
maxconn 2000
option tcplog
option dontlognull
timeout connect 20s
timeout client 10m
timeout server 10m
frontend httpid
mode tcp
bind *:443
acl hosts_sharepoint hdr_end(host) -i intranet.sharepoint.com
use_backend sharepoint if hosts_sharepoint
default_backend sharepoint
backend sharepoint
mode tcp
balance roundrobin
option redispatch
cookie SERVERID insert indirect nocache
server st1 xxx.xxx.xxx.xxx:443
option ssl-hello-chk
Auch command:
$ curl xxx.xxx.xxx.xxx:**80** --header 'Host: sharepoint.intranet.com' -vv
gibt 401 zurück, also funktioniert die Verbindung, aber command mit Port 443 $ url xxx.xxx.xxx.xxx:**443** --header 'Host: sharepoint.intranet.com' -vv
gibt zurück curl: (56) Recv failure: Connection reset by peer
. Ist meine Konfigurationsdatei korrekt? Oder muss ich vielleicht IIS konfigurieren?
ZWEITES UPDATE
Nach dem Neustart des SharePoint-Servers funktioniert diese Konfiguration mitDurchgang:
global
maxconn 4096
user haproxy
group haproxy
daemon
defaults
mode tcp
log 127.0.0.1 local0 notice
maxconn 2000
option tcplog
option dontlognull
timeout connect 20s
timeout client 10m
timeout server 10m
frontend httpid
mode tcp
bind *:443
acl hosts_sharepoint hdr_end(host) -i intranet.sharepoint.com
use_backend sharepoint if hosts_sharepoint
default_backend sharepoint
backend sharepoint
mode tcp
balance roundrobin
option redispatch
cookie SERVERID insert indirect nocache
server st1 xxx.xxx.xxx.xxx:443
option ssl-hello-chk
Antwort1
Sie sollten die Verwendung relativer Pfade in Konfigurationsdateien wie vermeiden ./cert.pem
. Bitte ändern Sie in einen absoluten Pfad wie /etc/ssl/cert.pem
(an den aktuellen Pfad anpassen).
Überprüfen Sie auch die cert.pem
Datei selbst. Sie sollte nur druckbaren Text (keinen Binärtext) mit mindestens zwei -----BEGIN CERTIFICATE-----
, -----END CERTIFICATE-----
Blöcken (Ihr Zertifikat und eine Zertifizierungsstelle aus der Kette) und einem -----BEGIN PRIVATE KEY-----
, -----END PRIVATE KEY-----
Block (oder möglicherweise einem -----BEGIN RSA PRIVATE KEY-----
, -----END RSA PRIVATE KEY-----
) enthalten.
Wenn die Datei Binärdateien enthielt cert.pem
, sollten Sie die Originaldateien ( cert.crt
, priv.key
) in das PEM-Format konvertieren und die cert.pem
Datei erneut erstellen. Die richtige Reihenfolge für die Verkettung sollte endgültiges Zertifikat, Schlüssel, unmittelbarer Aussteller, nächster Aussteller usw. sein. Sie können die Stammzertifizierungsstelle weglassen, da dies als bewährte Vorgehensweise gilt (keine wirkliche Notwendigkeit, weniger ausgetauschte Bytes).
Sie können mit OpenSSL vom Binärformat (auch DER genannt) in ein Textformat (auch PEM genannt) konvertieren:
Für die Zertifikate ( input.crt
wäre die DER-Datei und output.crt
die neue Datei im PEM-Format):
openssl x509 -inform DER -in input.crt -out output.crt
Zum Schlüssel (ich gehe davon aus, dass es sich um einen RSA-Schlüssel handelt, was am gebräuchlichsten ist): HINWEIS: Es wird nach einem (neuen) Passwort für gefragt output.key
, siehe meine Kommentare dazu später.
openssl rsa -inform DER -in Eingabe.Schlüssel -out Ausgabe.Schlüssel
HINWEIS: Die meisten Server gehen davon aus, dass der Schlüssel nicht verschlüsselt ist (das heißt, die nächste Zeile -----BEGIN PRIVATE KEY-----
enthält ENCRYPTED
). Wenn das der Fall ist und Ihr Server trotzdem nicht startet, versuchen Sie, den Schlüssel in ein unverschlüsseltes Format zu konvertieren (HINWEIS: Bei diesem Befehl gehe ich davon aus, dass die inputcipher.key
Datei bereits im PEM-Format vorliegt):
openssl rsa -in inputcipher.key -nodes -out outputclear.key
Was den Pass-Through mit dem 504
Fehler betrifft, verweisen Sie in der späteren Konfiguration auf , server st1 xxx.xxx.xxx.xxx:443
während Sie in der Intercept-Konfiguration auf verwiesen haben server spsrv xxx.xxx.xxx.xxx:80
. Bitte überprüfen Sie noch einmal, ob Ihr Backend auf Port 80 oder auf Port 443 lauscht, aber es scheint, dass auf Port 443 kein Backend lauscht.
Antwort2
Vielleicht hilft es jemandem. In meinem Fall habe ich unter Linux zwei Netzwerkadapter konfiguriert – ein lokales Netzwerk und ein öffentliches Netzwerk. Unter Windows habe ich nur ein lokales Netzwerk – Windows verbindet sich mit Linux im lokalen Netzwerk und dann kann ich über HAProxy die SharePoint-Site aus dem Internet öffnen.
Dies ist die richtige Konfiguration und funktioniert in meinem Fall (für SSL habe ich Pass-Through verwendet – Umleitung und Zertifikat befinden sich auf Windows IIS):
global
maxconn 4096
user haproxy
group haproxy
daemon
defaults
mode tcp
log 127.0.0.1 local0 notice
maxconn 2000
option tcplog
option dontlognull
timeout connect 20s
timeout client 10m
timeout server 10m
frontend httpid
mode tcp
bind *:443
acl hosts_sharepoint hdr_end(host) -i intranet.sharepoint.com
use_backend sharepoint if hosts_sharepoint
default_backend sharepoint
backend sharepoint
mode tcp
balance roundrobin
option redispatch
server st1 xxx.xxx.xxx.xxx:443 #local address of the Windows server
option ssl-hello-chk