AH01084:传递请求正文失败

问题描述 投票:0回答:1

我有使用 Ratchet 的基本聊天应用程序,它有像这样的服务器代码

<?php

use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use MyApp\Socket;

require dirname( __FILE__ ) . '/vendor/autoload.php';
require 'app/socket.php';
$server = IoServer::factory(
    new HttpServer(
        new WsServer(
            new Socket()
        )
    ),
    8445
);

$server->run();

我希望 websocket 与正常的 php 站点一起在我的域上运行,因此像这样配置了 apache 虚拟主机

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog /var/www/example.com/public_html/logs/error.log
    CustomLog /var/www/example.com/public_html/logs/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
     ServerName example.com
     ServerAlias www.example.com
     SSLProxyEngine on
     SSLProxyVerify none
     SSLProxyCheckPeerCN off
     SSLProxyCheckPeerName off
     SSLProxyCheckPeerExpire off
     SSLEngine on

     ProxyRequests Off

     Include /etc/letsencrypt/options-ssl-apache.conf
     SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

         DocumentRoot /var/www/example.com/public_html
         ErrorLog /var/www/example.com/public_html/logs/error.log
     CustomLog /var/www/example.com/public_html/logs/access.log combined

     ProxyPass / https://example.com:8445/
     ProxyPassReverse / https://example.com:8445/


        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
        RewriteRule .* wss://example.com:8445%{REQUEST_URI} [P]


</VirtualHost>


</IfModule>

我总是收到名为 500 代理错误的错误消息

 [proxy:error] [pid 18645] (20014)Internal error (specific information not available): [client 72.13.X.X:51606] AH01084: pass request body failed to 5.161.X.X:8445 (example.com)
[client 72.13.X.X:51606] AH00898: Error during SSL Handshake with remote server returned by /
[proxy_http:error] [pid 18645] [client 72.13.X.X:51606] AH01097: pass request body failed to 5.161.X.X:8445 (example.com) from 72.13.X.X ()

过去几个小时我一直在努力解决这个问题,但我无法让它工作。让我知道这里是否有人可以帮助我解决这个难题。 谢谢!

apache websocket reverse-proxy
1个回答
0
投票

使用后端 HTTP 节点的 IPv4 地址为我解决了这个问题。 所以,在你的 VirtualHost 上使用这个

     ProxyPass / https://72.13.X.X:8445/
     ProxyPassReverse / https://72.13.X.X:8445/

代替

     ProxyPass / https://example.com:8445/
     ProxyPassReverse / https://example.com:8445/
© www.soinside.com 2019 - 2024. All rights reserved.