Websocket proxy using nginx does not work with tomcat.

I am trying to proxy websocket to port 80 using nginx. We have a tomcat application running on port 8080 and the node application running on port 8888. I have been trying to proxy them to port 80 using nginx but for some reason the connection isn't being established. I am getting the following error in the console:

WebSocket connection to 'ws://chat-local-dev.guestops.com/ws/chat?access_token=bfb83713f8abecb6c3d36d3dc74c31b9&sessionId=undefined' failed: WebSocket is closed before the connection is established.

Here is my nginx configuration:

    worker_processes  1;
    events {
    worker_connections  1024;
    }
    http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
    listen       80;
    server_name  chat-local-dev.guestops.com;
    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
     } 
     }
     server {
     listen       80;
     server_name  api-local-dev.guestops.com;
     location / {
     proxy_pass http://localhost:8881;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
     proxy_set_header Host $host;
     }
     }
     server {
     listen       80;
     server_name  console-local-dev.guestops.com;
     location / {
     proxy_pass http://localhost:8888;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
     proxy_set_header Host $host;
     }
     }
     }

I am able to run the sites on port 80 but however I am unable to run the chat between client and the server.

Any help will be highly appreciated, I can provide with the node files as well but they are big bunch of files but I can provide with the necessary files if required.

I hope I am clear enough. Thanks in advance!

nginx added websocket support in version 1.3. So you have to upgrade to version 1.3.x to use it.