App Running on Digital Ocean Needs to Accept Websocket connections from clients

December 20, 2015 1.1k views
Deployment Networking Nginx Getting Started Ubuntu


I just created an Ubuntu-14.04 droplet on digital ocean.
I then deployed an application that used to previously run on my desktop.
On my test laptop the App was running on localhost. Client used to open websocket connections to localhost.

Now I have deployed app to DigitalOcean Droplet and would like client to connect to App using the same method.
I have verified that my application runs on Digital Ocean but does not accept incoming connections.

My question(s):

  1. What are the minimum components that I need to install on my droplet ?
    -- Deploy App (yes)
    -- HTTP server/Load Balancer (?? not sure)
    -- What else is needed ??

  2. What URL should my client use if I need to connect to my App running on the DigialOcean droplet ?

  3. Does my Client need to use secure websockets to make sure that it gets to my App ? I would initially like to use ordinary websockets (not secure) to begin with and switch to secure websockets when development has progressed enough.
    Basically I want to address all security concernes at a later time after basic application is running.

Any pointers or information to my above 3 questions will be highly appreciated.

Thank you.

1 Answer

1. You could set up Nginx as a websocket proxy.
Be sure to set the appropriate HTTP headers:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

2. The URL depends on your proxy setup, if there is nothing else on port 80, you can just use the IP of your Droplet, or whatever domain (or subdomain) you have delegated to that IP address.

3. SSL is not necessary as far as I know.

Have another answer? Share your knowledge.