7

I got an error 500 when trying to access to ws://localhost:8080/ via my Apache2 server. This server runs 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 works fine. URL example: http://<myhost-ip-address>/api/ws/<some-url>. It returns status 101 and the response: Upgrade: websocket. It's OK.

The same kind of request from external network fails. 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 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:

<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 answers (thank to that): websockets , node.js , socket-io , but with no luck.

Something must be wrong in my configuration. Any ideas?

jack-y
  • 171
  • 1
  • 1
  • 2

1 Answers1

3

Looks like you are missing mod_proxy_wstunnel module which is required for Websockets support.

It should be enabled like below in your httpd.conf

LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so

Install the module & then it should work fine.

serverliving.com
  • 875
  • 6
  • 15
  • 1
    As I said, these Apache2 modules are enabled: mod_proxy, mod_proxy_http, mod_proxy_wstunnel. So `mod_proxy_wstunnel` has been enabled. That's why I don't understand ;) – jack-y Jun 09 '16 at 09:32
  • ah ok. Did not notice that. But the error message says that the required module to process was not loaded – serverliving.com Jun 09 '16 at 09:41
  • Are you trying to access it as http://www.example.com/api/ws/ or ws://www.example.com/api/ws/ ?. I believe you will need to use http – serverliving.com Jun 09 '16 at 09:44
  • May be you're right. I access it as `ws://www.example.com/api/ws/`. It is requested by the company. Is there a way to do it? – jack-y Jun 09 '16 at 09:56
  • Not sure if there are such implementations available for running apache over ws:// . In normal scenario, you will access the ws server via http. May be you can try https://github.com/google/pywebsocket – serverliving.com Jun 09 '16 at 10:42
  • Thanks @serverliving! I'll try and tell you what it has given very soon. – jack-y Jun 09 '16 at 12:06
  • @jack-y did you ever resolve this? I have been trying to work this out now for nearly 2 weeks! – adamteale Jan 04 '17 at 12:17
  • @adamteale Unfortunately no. I spent a lot of time finding a solution, but without success. I moved on. Hope you will be luckier. – jack-y Jan 06 '17 at 13:16
  • I think I am halfway there (i've had some great help from the apache mailing list) - however I am now getting an error saying that the server is not responding with an Upgrade Header. I'll let you know when I get it solved – adamteale Jan 06 '17 at 13:20