下記に更新

下記に更新

下記に更新

________________

SharePoint サイトのリバース プロキシとして HAProxy を使用することにしましたが、SSL なしではすべて正常に動作しますが、SSL があると haproxy.service を起動できません。さまざまな構成を試しましたが、解決できません...

サービスを開始しようとしています:

$ 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.

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'.

構成ファイルの問題を確認しています:

$ 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

ログ:

 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.

別のサーバーの nginx に同じ証明書 (ただし、証明書、キー、チェーンに分割) を使用しており、正常に動作しています。cat cert.crt priv.key certchain.crt > cert.pemコマンドを使用して HAProxy 用にこれを作成し、さまざまな順序で試しましたが、エラーは同じです。また、コマンドhaproxy -c -f haproxy.cfgサーバーでパスフレーズを要求されているため、証明書は正常 (間違っている可能性があります) であり、構成ファイルに問題があると思います。ご協力いただきありがとうございます。

私の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

最初の更新

パススルーを試したところ、SharePoint がポート 80 で資格情報を要求し (IIS ロールを無効にした後)、その後 SharePoint がエラー「504 ゲートウェイ タイムアウト」で https にリダイレクトされます。これが現在の 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

また、コマンド: $ curl xxx.xxx.xxx.xxx:**80** --header 'Host: sharepoint.intranet.com' -vvは 401 を返すので接続は機能していますが、ポート 443 のコマンド$ url xxx.xxx.xxx.xxx:**443** --header 'Host: sharepoint.intranet.com' -vvは を返しますcurl: (56) Recv failure: Connection reset by peer。構成ファイルは正しいですか? それとも、IIS を構成する必要があるのでしょうか?

2回目の更新

SharePointサーバーを再起動すると、この構成は機能しますパススルー:

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

答え1

設定ファイルでは、 のような相対パスの使用は避けてください./cert.pem。 のような絶対パスに変更してください/etc/ssl/cert.pem(現在のパスに合わせてください)。

また、cert.pemファイル自体も確認してください。ファイルには、少なくとも 2 つの-----BEGIN CERTIFICATE-----,-----END CERTIFICATE-----ブロック (証明書とチェーンの CA) と , ブロック(または , ) を含む印刷可能なテキスト (バイナリではない) のみが含まれている必要が-----BEGIN PRIVATE KEY-----あります。-----END PRIVATE KEY----------BEGIN RSA PRIVATE KEY----------END RSA PRIVATE KEY-----

ファイル内にバイナリが含まれていた場合はcert.pem、元のファイル ( cert.crtpriv.key) を PEM 形式に変換し、cert.pemファイルを再作成する必要があります。連結の正しい順序は、最終証明書、キー、直近の発行者、次の発行者などです。ルート CA は含めない方がよいと考えられているため、省略できます (実際に必要なく、交換されるバイト数が少なくなるため)。

openssl を使用して、バイナリ形式 (DER とも呼ばれる) をテキスト形式 (PEM とも呼ばれる) に変換できます。

証明書の場合 (input.crtは DER ファイル、output.crtは PEM 形式の新しいファイルになります):

openssl x509 -inform DER -in input.crt -out output.crt

キーについては(最も一般的な RSA キーであると想定しています)注: の(新しい)パスワードが要求されます。output.keyこれについては後で私のコメントを参照してください。

openssl rsa -inform DER -in 入力キー -out 出力キー

注: ほとんどのサーバーでは、キーが暗号化されていない (つまり、 の次の行に が-----BEGIN PRIVATE KEY-----含まれているENCRYPTED) と想定しています。その場合でもサーバーが起動しない場合は、キーを暗号化されていない形式に変換してみてください (注: このコマンドでは、ファイルがすでに PEM 形式であると想定していますinputcipher.key)。

openssl rsa -in 入力暗号キー -nodes -out 出力クリアキー

エラーのあるパススルーについては504、後の設定では を指していますserver st1 xxx.xxx.xxx.xxx:443が、インターセプト設定では を指していますserver spsrv xxx.xxx.xxx.xxx:80。バックエンドがポート 80 でリッスンしているか、ポート 443 でリッスンしているかを再確認してください。ただし、443 でリッスンしているバックエンドはないようです。

答え2

誰かの役に立つかもしれません。私の場合、Linux にローカル ネットワークとパブリック ネットワークの 2 つのネットワーク アダプターを構成しました。Windows にはローカル ネットワークしかありません。Windows はローカル ネットワークで Linux に接続し、HAProxy を介してインターネットから SharePoint サイトを開くことができます。

これは正しい構成であり、私のケースでは機能します (SSL の場合、パススルー - リダイレクトを使用し、証明書は 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

関連情報