0

I have everything being proxy correctly just that my websockets keep giving me an unexpected 200 response error. I am using native websockets on chrome and firefox.

my conf file looks like this

<VirtualHost example.com:80>
ServerName example.com
ProxyRequests Off
ProxyPass /websocket/ ws://localhost:8080/XXXXX/websocket/ retry=0
ProxyPassReverse /websocket/ ws://localhost:8080/XXXXX/websocket/ retry=0
ProxyPass / http://localhost:8080/XXXXX/
ProxyPassReverse / http://localhost:8080/XXXXX/
ProxyPassReverseCookiePath /XXXXX /
</VirtualHost>

Here is the exact error, so there is no confusion.

Error during WebSocket handshake: Unexpected response code: 200
italiano40
  • 496
  • 9
  • 18
  • localhost would proxy to the box you are making the request from. is that the intention? – Paul Frederiksen Aug 28 '14 at 04:53
  • @PaulFrederiksen The intention is to have wstunnel take the request over to tomcat7, which it seems to be doing, but at some point apache is sending a bad 200 response back to the websocket client. – italiano40 Aug 28 '14 at 05:25
  • hitting those urls manually works? Are the links on "localhost" relative? – Paul Frederiksen Aug 28 '14 at 05:28
  • @PaulFrederiksen I think you have misunderstood the problem at hand. Those URLS work, but for some reason after enabling mod_proxy_wstunnel it is not being treat as a websocket url when it matches. Hence me getting the 200 response which means I am not using http 1.1 or apache is stripping out the headers. I need to figure out how to prevent both from happening, so it gets to tomcat and back to the client. – italiano40 Aug 28 '14 at 05:56
  • mod_proxy_wstunnel doesn't work in all circumstances although if all your websocket endpoints are under /websocket you should be OK. It is apps that mix WebSocket and HTTP onthe same URL that it doesn't handle. I'd suggest using Wireshark to see exactly what is going on on the httpd <-> Tomcat connection. – Mark Thomas Aug 29 '14 at 06:06

1 Answers1

1

I had a similar Problem with modproxy and wstunnel module in apache2 version 2.4.10 on Ubuntu 15.04. I used tcpflow to figure out what happened and saw that my HTTP Proxy worked correctly and sent everything to my nodejs server, but my websocket Proxy directly returned the website at /.

Luckily, i had a working Debian server with nearly the same configuration, and I found out the only difference was the following:

On the non-working server:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

On the working server:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

I don't know why this worked in my case, but I hope adding the Directory directive to your VirtualHost will solve your Problem too.

Daniel Abrecht
  • 133
  • 1
  • 6