I deployed a Meteor app to a DO Droplet using MeteorUp. I configured apache's Virtual Hosts for this website like this:

<VirtualHost *:80>
    ServerName filipe-garcia.com
    ServerAlias www.filipe-garcia.com

    ServerAdmin me@filipe-garcia.com
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/sockjs/           [NC]
    RewriteCond %{QUERY_STRING} transport=websocket [NC]
    RewriteRule /sockjs/ ws://localhost:3000/$1     [P,L]

    ProxyPreserveHost On
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

But I'm still getting a

WebSocket connection to 'ws://filipe-garcia.com/sockjs/622/9hwpvs81/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

error on my console. I have googled this and found a multitude of solutions (mostly variations of this same VHosts), without success on any.

Everything else seems to be working perfectly, except for this error (which I have not yet felt anything because of it, because this app is not relying on websockets yet).

I'm not sure how I should fix this. I'm running Apache 2.4.7 on Ubuntu 32bits and I have proxy, proxy_connect, proxy_http, proxy_wstunnel enabled.

EDIT: It must have something to do with the way the proxy is configured, because if I point my browser to the machine and port it is running on directly, this error does not happen.

As a tiny bonus question, by using a nodejs server, should I remove the DocumentRoot line of the file or just leave it there?

Thank you.

  • I've same same issue, Can you please tell me how did you solve it ? plsss – Nullpointer Dec 17 '16 at 9:32

For me.. simply adding the following to ..sites-enabled..(ubuntu+apache) worked for me:

ProxyRequests off
   <Proxy *>
    Order deny,allow
    Allow from all

   <Location />
    ProxyPass http://localhost:3000/
    ProxyPassReverse http://localhost:3000/

Make sure you add to sites-enabled not sites-available

  • Hmm.. tried that... Doesn't work :S BTW, it is on sites-enabled indeed... So, not that.. – fgarci03 Dec 9 '15 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.