WS Protocol and Apache Mod_Proxy_Wstunnel configuration: error 500

I receive error 500 when trying to access ws through my Apache2 server: // localhost:8080 /. The server is running OpenSuse Leap 42.1 and Apache 2.4.16.

These Apache2 modules are enabled: mod_proxy,mod_proxy_http,mod_proxy_wstunnel.

When the request is called from the local network, everything is normal. URL example: http://< myhost-ip-address> / api / ws /. It returns status 101 and response: Upgrade: websocket. It’s okay.

A similar request from an external network failed. URL example: ws: //www.mysite.com/api /ws/< some-url>. It returns error 500.

The Apache access log contains: GET / api / ws /< some-url> HTTP / 1.1 “500 ……

The Apache error log contains: [proxy:warn] AH01144: No protocol handler is valid for URL/api/ws/. If you are using the DSO version of mod_proxy, please make sure to use LoadModule in the configuration Contains proxy submodule.

My httpd.conf:


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://lo calhost: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

Options Indexes SymLinksIfOwnerMatch
AllowOverride None
...

# URL as parameter
AllowEncodedSlashes NoDecode

I followed the previous StackOverflow answer (thank God):
websockets, node.js, socket-io, but no luck.

There must be a problem with my configuration. Any ideas?

Edit

As suggested by adona9, here is the debug log:

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
...< br />mod_authz_core.c(809): AH01626: authorization result of Require user : granted
mod_authz_core.c(809): AH01626: authorization result of : 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/
mod_proxy_wstunnel.c(341): AH02900: declining URL ws://localhost:8080/api/ws/ (not WebSocket)
[proxy:warn] H01144: No protocol handler was valid for the URL /api/ws/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadMo dule.

Any ideas?

So I finally spent a day and a half studying and reading the in-depth apache2 configuration. This is how I can The solution to this problem:

>Use forensic_logs and DumpIO to find my initial request headers on the apache2 side.
>Record the request headers from the websocket client.

< p>Verify that both include the upgrade header in the request header and the connection type websocket. These problems are most likely the result of network filtering or removal of specific header files.

My problem is that I am using AWS classic load balancer, it does not support websocket connections.

When reading other forums, some company firewalls will also remove specific header files from their connections, so it may also be the case.

p>

So, if you do a triple check to make sure that the correct module is installed, then the error is likely to be network-related.

If you have a network diagram, check each specific node and gateway, And verify that the input and output request headers are the same.

I receive error 500 when trying to access ws through my Apache2 server: // localhost:8080 /. The server is running OpenSuse Leap 42.1 and Apache 2.4.16.

These Apache2 modules are enabled: mod_proxy, mod_proxy_http, mod_proxy_wstunnel.

When the request is called from the local network, everything is normal. URL example : Http: //< myhost-ip-address> / api / ws /< some-url>. It returns status 101 and response: Upgrade: websocket. It’s okay.

The similar request from the external network failed . URL example: ws: //www.mysite.com/api/ws/< some-url>. It returns error 500.

The Apache access log contains: GET / api / ws /< some-url> HTTP / 1.1 “500 ……

The Apache error log contains: [proxy: warn] AH01144: No protocol handler is valid for URL / api / ws /< some-url>. If you The DSO version of mod_pr is used oxy, please make sure to use LoadModule to include the proxy submodule in the configuration.

My httpd.conf:


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

Options Indexes SymLinksIfOwnerMatch
AllowOverride None
...

# URL as parameter
AllowEncodedSlashes NoDecode

I followed the previous StackOverflow answer (thank god):
websockets, node.js, socket-io, but no luck.

There must be something wrong with my configuration. Any ideas?

Edit

As suggested by adona9, here is the debug log:

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
...< br />mod_authz_core.c(809): AH01626: authorization result of Require user : granted
mod_authz_core.c(809): AH01626: authorization result of : 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/
mod_proxy_wstunnel.c(341): AH02900: declining URL ws://localhost:8080/api/ws/ (not WebSocket)
[proxy:warn] H01144: No protocol handler was valid for the URL /api/ws/. 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 finally spent a day and a half studying and reading the in-depth apache2 configuration. This is how I was able to solve this problem:

>Use forensic_logs and DumpIO to find my initial request headers on the apache2 side.
>Record the request headers from the websocket client.

Verify that both include the request headers Upgrade the header and connection type websocket. These problems are most likely the result of network filtering or removal of specific header files.

My problem is that I am using AWS classic load balancer, which does not support websocket connections.

When reading other forums, some companies’ firewalls also remove specific header files from their connections, so it may also be the case.

So, if you do a triple check To ensure that the correct module is installed, then it is likely that the error is related to the network.

If you have a network diagram, check each specific node and gateway, and verify that the input and output request headers are the same.< /p>

Leave a Comment

Your email address will not be published.