Giter Site home page Giter Site logo

wrightrocket / nodedeploy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miserlou/nodedeploy

0.0 2.0 0.0 72 KB

Example scripts for deploying a Node.js application behind a Node proxy alongside Apache/Nginx, as a demon which restarts automatically upon crashing.

Home Page: http://gun.io/blog/tutorial-deploy-node-js-server-with-example/

nodedeploy's Introduction

Node Deploy Files

Rich Jones - [email protected]

This is a living document! Please let me know if I'm doing anything really stupid here. Patches graciously accepted. Tutorial form available here.

Our goal:

  • Run a Node-based front end proxy which proxies to a Node app and either Apache or Nginix, depending on the hostname.
  • Must support WebSockets served from SocketIO.
  • If the node app crashes (which it will), it must restart.
  • Servers must start upon the boot of the machine.
  • It must be secured with SSL. [TODO]
  • Incoming 80 traffic -> Firewall -> Proxy (8000) -> Node (8080) OR -> Apache (9000)

Tools:

  • Node.js, NPM, Apache or Nginx (duh)
  • Socket.io for WebSockets
  • node-http-proxy (https://github.com/nodejitsu/node-http-proxy)
    • We are choosing this over 'bouncy' because it is slightly faster and there are more examples dealing with SSL, although the API is slightly worse. It's also made by Nodejitsu, who seem knowledgable and responsive.
  • Monit, for monitoring the node applications.
  • sudo apt-get install monit

Files included here:

  • /etc/init.d/YOUR_APP - an init.d script for your node app.
  • /etc/init.d/http-proxy - an init.d script for your proxy.
  • /var/www/yourapp/proxy.js - the proxy!
  • /var/www/yourapp/server.js - placeholder server code.
  • /etc/monit/monitrc - the monit resource for checking our server health

Notes:

You don't want to run node as root in production. Instead, you can run it as a higher port and forward all 8080 traffic to it. This seems a little fucked to me - should be changed to just drop permissions after starting proxy server.

# REDIRECT port 80 to 8000 $IPTABLES -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8000

Sources:

nodedeploy's People

Watchers

WrightRocket 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.