简体   繁体   English

ws protocol和apache mod_proxy_wstunnel配置:错误500

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

I got an error 500 when trying to access to ws://localhost:8080/ via my Apache2 server. 尝试通过我的Apache2服务器访问ws:// localhost:8080 /时收到错误500。 This server runs OpenSuse Leap 42.1 and Apache 2.4.16. 该服务器运行OpenSuse Leap 42.1和Apache 2.4.16。

These Apache2 modules are enabled: mod_proxy, mod_proxy_http, mod_proxy_wstunnel. 启用了这些Apache2模块:mod_proxy,mod_proxy_http,mod_proxy_wstunnel。

When the request is called from the local network, everything works fine. 从本地网络调用请求时,一切正常。 URL example: http://<myhost-ip-address>/api/ws/<some-url> . URL示例: http://<myhost-ip-address>/api/ws/<some-url> It returns status 101 and the response: Upgrade: websocket . 它返回状态101和响应: Upgrade: websocket It's OK. 没关系。

The same kind of request from external network fails. 来自外部网络的同类请求失败。 URL example: ws://www.mysite.com/api/ws/<some-url> . URL示例: ws://www.mysite.com/api/ws/<some-url> It returns error 500. 它返回错误500。

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

The Apache error log contains: [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. 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.

My httpd.conf: 我的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

I followed these previous StackOverflow answers (thank to that) : websockets , node.js , socket-io , but with no luck. 我按照之前的StackOverflow回答(感谢): websocketsnode.jssocket-io ,但没有运气。

Something must be wrong in my configuration. 我的配置一定有问题。 Any ideas ? 有任何想法吗 ?

EDIT 编辑

As suggested by adona9, here are debug logs: 正如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.

Any ideas ? 有任何想法吗 ?

So I ended up spending a day and a half researching and reading up on deep apache2 configuration. 所以我最终花了一天半的时间研究和阅读深度apache2配置。 This is how I was able to solve this problem: 这就是我能够解决这个问题的方法:

  • Using both forensic_logs and DumpIO to find out my initial request headers on the apache2 end. 使用forensic_logs和DumpIO在apache2端找到我的初始请求头。

  • Log the request headers coming from websocket client. 记录来自websocket客户端的请求标头。

VERIFY that both contain the upgrade header and connection type websocket in the request header. 验证两者都包含请求标头中的升级标头和连接类型websocket。 More than likely, these problems are a result of network filtering or removing of specific header files. 这些问题很可能是网络过滤或删除特定头文件的结果。

My problem was that I was using an AWS classic load balancer which DOES NOT support websocket connections. 我的问题是我使用的是AWS经典负载均衡器,它不支持websocket连接。

While reading other forums, some companies' firewalls also remove specific header files from their connections, so it could also be that. 在阅读其他论坛时,一些公司的防火墙也会从其连接中删除特定的头文件,因此它也可能就是这样。

So more than likely if you've triple-checked to make sure you have the right modules installed, the more than likely error is network related. 因此,如果您进行三重检查以确保安装了正确的模块,那么很可能错误与网络相关。

If you have a network diagram, check each specific node and gateway and verify that the in and out request headers are the same. 如果您有网络图,请检查每个特定节点和网关,并验证输入和输出请求标头是否相同。

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

相关问题 Apache / 2.4.18(Ubuntu)mod_proxy_wstunnel - Apache/2.4.18 (Ubuntu) mod_proxy_wstunnel 如何在Raspberry Pi(Backport mod_proxy_wstunnel)上将mod_proxy_wstunnel添加到Apache2 2.2 - How to add mod_proxy_wstunnel to Apache2 2.2 on Raspberry Pi (Backport mod_proxy_wstunnel) WebSockets 和 Apache 代理:如何配置 mod_proxy_wstunnel? - WebSockets and Apache proxy : how to configure mod_proxy_wstunnel? 在Apache mod_proxy_wstunnel后面使用go-websocket - Using go-websocket behind Apache mod_proxy_wstunnel 在Apache 2.4.x上配置mod_proxy_wstunnel - configure mod_proxy_wstunnel on apache 2.4.x mod_proxy_wstunnel-Mac OS X 10.11.6,Apache 2.4.18 - mod_proxy_wstunnel - Mac OS X 10.11.6, Apache 2.4.18 如何在CentOS上的Apache 2.2上设置mod_proxy_wstunnel - How to set up mod_proxy_wstunnel on Apache 2.2 on CentOS WebSocket握手期间出错:缺少“升级”标头(Apache 2.4 + mod_proxy_wstunnel) - Error during WebSocket handshake: 'Upgrade' header is missing (Apache 2.4 + mod_proxy_wstunnel) 将Apache WebSocket重定向到Tomcat:mod_proxy和mod_proxy_wstunnel - Apache websocket redirection to Tomcat: mod_proxy and mod_proxy_wstunnel 带有Apache mod_proxy_wstunnel的Websocket到带有javax.servlet.request.X509的tomcat - Websocket with apache mod_proxy_wstunnel to tomcat with javax.servlet.request.X509Certificate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM