아래 업데이트

아래 업데이트

아래 업데이트

________________

HAProxy를 SharePoint 사이트의 역방향 프록시로 사용하기로 결정했는데 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에 대해 동일한 인증서(그러나 나누어져 있음: 인증서, 키, 체인)를 사용하고 있으며 작동합니다. 명령을 사용하여 HAProxy용으로 만들었고 cat cert.crt priv.key certchain.crt > cert.pem다른 순서로 시도했지만 오류는 동일합니다. 또한 명령 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' -vv401을 반환하므로 연결이 작동하지만 포트 443을 사용한 명령은 을 $ url xxx.xxx.xxx.xxx:**443** --header 'Host: sharepoint.intranet.com' -vv반환합니다 curl: (56) Recv failure: Connection reset by peer. 내 구성 파일이 정확합니까? 아니면 IIS를 구성해야 합니까?

두 번째 업데이트

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.crt, priv.key)을 PEM 형식으로 변환한 후 cert.pem파일을 다시 생성해야 합니다. 연결의 올바른 순서는 최종 인증서, 키, 즉시 발급자, 다음 발급자 등이어야 합니다. 루트 CA는 포함하지 않는 것이 좋은 방법으로 간주되므로 생략할 수 있습니다(실제 필요 없음, 교환되는 바이트 수가 적음).

openssl을 사용하여 바이너리 형식(DER이라고도 함)을 텍스트 형식(PEM이라고도 함)으로 변환할 수 있습니다.

인증서의 경우( input.crtDER 파일이고 output.crtPEM 형식의 새 파일임):

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

키의 경우(가장 일반적인 RSA 키라고 가정합니다.) 참고: 에 대한 (새) 비밀번호를 묻는 메시지가 표시됩니다. output.key이에 대한 나중에 설명을 참조하세요.

openssl rsa -inform DER -in input.key -out output.key

참고: 대부분의 서버는 키가 암호화되지 않았다고 가정합니다(즉, Contains 의 다음 줄 -----BEGIN PRIVATE KEY-----) ENCRYPTED. 이 경우에도 서버가 여전히 시작되지 않으면 키를 암호화되지 않은 형식으로 변환해 보십시오(참고: 이 명령에서는 파일이 inputcipher.key이미 PEM 형식이라고 가정합니다).

openssl rsa -in inputcipher.key -nodes -out outputclear.key

오류 가 있는 통과의 경우 504이후 구성에서는 을 가리키는 server st1 xxx.xxx.xxx.xxx:443반면, 인터셉트 구성에서는 를 가리키고 있습니다 server spsrv xxx.xxx.xxx.xxx:80. 백엔드가 포트 80 또는 포트 443에서 수신 대기 중인지 다시 확인하세요. 하지만 443에서 수신 대기 중인 백엔드가 없는 것 같습니다.

답변2

어쩌면 누군가에게 도움이 될 것입니다. 제 경우에는 Linux에 로컬 네트워크와 공용 네트워크라는 두 개의 네트워크 어댑터를 구성했습니다. 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

관련 정보