繁体   English   中英

ws protocol和apache mod_proxy_wstunnel配置:错误500

[英]ws protocol and apache mod_proxy_wstunnel configuration: error 500

尝试通过我的Apache2服务器访问ws:// localhost:8080 /时收到错误500。 该服务器运行OpenSuse Leap 42.1和Apache 2.4.16。

启用了这些Apache2模块:mod_proxy,mod_proxy_http,mod_proxy_wstunnel。

从本地网络调用请求时,一切正常。 URL示例: http://<myhost-ip-address>/api/ws/<some-url> 它返回状态101和响应: Upgrade: websocket 没关系。

来自外部网络的同类请求失败。 URL示例: ws://www.mysite.com/api/ws/<some-url> 它返回错误500。

Apache访问日志包含: GET /api/ws/<some-url> HTTP/1.1" 500 ...

Apache错误日志包含: [proxy:warn] AH01144: No protocol handler was valid for the URL /api/ws/<some-url>. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule. [proxy:warn] AH01144: No protocol handler was valid for the URL /api/ws/<some-url>. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

我的httpd.conf:

<VirtualHost *:80>
ServerName mysite.com
ServerAlias mysite.com
# Redirection for ws protocol
ProxyPreserveHost On
ProxyVia full
ProxyRequests OffHere
RewriteEngine On
RewriteCond %{REQUEST_URI}  ^/api/ws/(.*)           [NC]
RewriteCond %{QUERY_STRING} transport=websocket     [NC]
RewriteRule /(.*)           ws://localhost:8080/$1  [P,L]
# Proxy pass
ProxyPass           /api/ws/            ws://localhost:8080/api/ws/
ProxyPassReverse    /api/ws/            ws://localhost:8080/api/ws/
# DocumentRoot
DocumentRoot /srv/www/vhosts/mysite.com
<Directory "/srv/www/vhosts/mysite.com">
    Options Indexes SymLinksIfOwnerMatch
    AllowOverride None
    ...
</Directory>
# URL as parameter
AllowEncodedSlashes NoDecode

我按照之前的StackOverflow回答(感谢): websocketsnode.jssocket-io ,但没有运气。

我的配置一定有问题。 有任何想法吗 ?

编辑

正如adona9所建议的,这里是调试日志:

proxy_util.c(1784): AH00925: initializing worker ws://localhost:8080/api/ws/ shared
proxy_util.c(1826): AH00927: initializing worker ws://localhost:8080/api/ws/ local
...
mod_authz_core.c(809): AH01626: authorization result of Require user <user>: granted
mod_authz_core.c(809): AH01626: authorization result of <RequireAny>: granted
mod_charset_lite.c(219): AH01448: incomplete configuration: src unspecified, dst unspecified
mod_proxy.c(1159): AH01143: Running scheme ws handler (attempt 0)
mod_proxy_http.c(1944): AH01113: HTTP: declining URL ws://localhost:8080/api/ws/<some-url>
mod_proxy_wstunnel.c(341): AH02900: declining URL ws://localhost:8080/api/ws/<some-url>  (not WebSocket)
[proxy:warn] H01144: No protocol handler was valid for the URL /api/ws/<some-url>. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

有任何想法吗 ?

所以我最终花了一天半的时间研究和阅读深度apache2配置。 这就是我能够解决这个问题的方法:

  • 使用forensic_logs和DumpIO在apache2端找到我的初始请求头。

  • 记录来自websocket客户端的请求标头。

验证两者都包含请求标头中的升级标头和连接类型websocket。 这些问题很可能是网络过滤或删除特定头文件的结果。

我的问题是我使用的是AWS经典负载均衡器,它不支持websocket连接。

在阅读其他论坛时,一些公司的防火墙也会从其连接中删除特定的头文件,因此它也可能就是这样。

因此,如果您进行三重检查以确保安装了正确的模块,那么很可能错误与网络相关。

如果您有网络图,请检查每个特定节点和网关,并验证输入和输出请求标头是否相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM