Nginx 업스트림 wss 프록시 SSL_read()가 실패했습니다(SSL: 오류:0A000126:SSL 루틴::읽는 동안 예기치 않은 eof)

Nginx 업스트림 wss 프록시 SSL_read()가 실패했습니다(SSL: 오류:0A000126:SSL 루틴::읽는 동안 예기치 않은 eof)

나에게 필요한 것은

Client <--wss---> nginx <--wss--> server

wss 프록시를 수행 중입니다. 이미 Apache에서 작동하고 있지만 이제 nginx로 전환하고 싶습니다. Apache 구성은 다음과 같습니다.

<LocationMatch "/statistics">
        ProxyPass wss://127.0.0.1:23456
        ProxyAddHeaders Off
        ProxyPreserveHost On
        RequestHeader set Host %{HTTP_HOST}s
        RequestHeader set X-Forwarded-For %{REMOTE_ADDR}s
</LocationMatch>

nginx에서는 이 구성을 사용합니다./etc/nginx/nginx.conf

server {
        listen       444 ssl;
        listen       [::]:444 ssl;
        server_name  domain.com www.domain.com;
        root         /usr/share/nginx/html;

        ssl_certificate "/etc/letsencrypt/live/domain/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/domain/privkey.pem";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;

        ssl_prefer_server_ciphers on;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


    proxy_ssl_server_name on;
    ssl_protocols TLSv1.2 TLSv1.3;
location /statistics {
    proxy_pass https://127.0.0.1:23456;

    proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header Host $host;
      proxy_ssl_name $host;
    proxy_ssl_session_reuse off;


      proxy_ssl_certificate "/etc/letsencrypt/live/domain/fullchain.pem";
      proxy_ssl_certificate_key "/etc/letsencrypt/live/domain/privkey.pem";


      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
}

내 웹사이트는 SSL 오류 없이 Nginx에서 잘 로드됩니다. 작동하지 않는 것은 wss가 있는 websocket이고 ws가 있는 websocket도 작동한다는 것입니다!

wscat실행 중인 연결을 테스트하는 데 사용합니다 .

wscat -c wss://kaveneger.ir:23456
Connected (press CTRL+C to quit)
> 

내 엔드포인트가 괜찮다는 뜻입니다. (아파치에서 작동하기 때문에 이 테스트가 실제로 필요하지는 않았지만 어쨌든...)

이제 nginx로 할 때입니다.

wscat -c wss://domain.com:444/statistics
error: Unexpected server response: 404
> %                                                                             

Nginx 로그

/var/log/nginx/access.log

123.123.123.123 - - [27/Feb/2023:21:53:15 +0000] "GET /statistics HTTP/1.1" 404 0 "-" "-" "-"

/var/log/nginx/error.log

2023/02/27 21:53:49 [crit] 70632#70632: *14 SSL_read() failed (SSL: error:0A000126:SSL routines::unexpected eof while reading) while keepalive, client: 123.123.123.123, server: 0.0.0.0:444

내 OS는 Rocky Linux 9이고 nginx 버전은 nginx/1.20.1입니다.

이미 많이 검색하고 찾은 모든 솔루션을 시도했지만 아무 효과가 없었습니다!


업데이트

location /대신에 사용하면 작동합니다 location /statistics!

관련 정보