Giter Club home page Giter Club logo

passenger-nodejs-websocket-demo's Introduction

Phusion Passenger: Node.js WebSocket demo

This application demonstrates WebSocket support in the Phusion Passenger application server for Node.js, through the use of the awesome Socket.io library. Passenger supports all major modern web technologies, such as WebSockets, entirely out of the box. You don't have to do anything: WebSocket support just works.

If you like this demo, please tweet about it or follow us on Twitter.

See also: >> What is Phusion Passenger, and why should I care?

Node.js

Phusion Passenger

Getting started

Preparations

  1. Install Phusion Passenger 4.0.37 or later.

  2. Clone this repository:

    git clone https://github.com/phusion/passenger-nodejs-websocket-demo.git
    cd passenger-nodejs-websocket-demo
    
  3. Install dependencies:

    npm install socket.io
    

Running the demo in Passenger Standalone

Run:

passenger start

Access the demo application at http://0.0.0.0:3000/ and see it in action.

Running the demo in Passenger for Nginx

Create a virtual host in your Nginx configuration file:

server {
    listen 3000;
    server_name passenger-nodejs-websocket.demo;
    root /path-to/passenger-nodejs-websocket-demo/public;
    passenger_enabled on;
}

Add passenger-nodejs-websocket.demo to your /etc/hosts:

echo 127.0.0.1 passenger-nodejs-websocket.demo | sudo tee -a /etc/hosts

Then restart Nginx, and access the demo application at http://passenger-nodejs-websocket.demo:3000/

Running the demo in Passenger for Apache

Apache itself doesn't work very well with WebSockets, so running in Apache is not recommended. Having said that, Socket.io gracefully falls back to polling when run on Apache, so the demo still works.

Create a virtual host in your Apache configuration file:

# Comment out if you already have a "Listen 3000" directive somewhere.
Listen 3000
# Comment out when using Apache >= 2.4.
NameVirtualHost *:3000

<VirtualHost *:3000>
    ServerName passenger-nodejs-websocket.demo
    DocumentRoot /path-to/passenger-nodejs-websocket-demo/public
</VirtualHost>

Add passenger-nodejs-websocket.demo to your /etc/hosts:

echo 127.0.0.1 passenger-nodejs-websocket.demo | sudo tee -a /etc/hosts

Then restart Apache, and access the demo application at http://passenger-nodejs-websocket.demo:3000/

Running the demo in Node.js without Passenger

Run:

node app.js

Then access the demo application at http://0.0.0.0:3000/

Next steps

Please enjoy Phusion Passenger, a product by Phusion. :-)

About Phusion Passenger


5 minute intro: Making Node.js deployment enjoyable (DotJS Paris 2013)


Phusion Passenger used in Game of Thrones Ascention

Phusion Passenger™ is a web server and application server, designed to be fast, robust and lightweight. It takes a lot of complexity out of deploying web apps, adds powerful enterprise-grade features that are useful in production, and makes administration much easier and less complex. Phusion Passenger supports Ruby, Python, Node.js and Meteor, and is being used by high-profile companies such as Apple, Pixar, New York Times, AirBnB, Juniper etc as well as over 350.000 websites.

Learn more: Website | Documentation | Support resources | Github | Twitter | Blog

passenger-nodejs-websocket-demo's People

Contributors

duritong avatar foobarwidget avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.