5 ms·
It's probably a better idea to just run nginx on port 80 and proxy requests through in any sort of real environment. And if you're not in production...well, it
by wonnage 14y ago
It's probably a better idea to just run nginx on port 80 and proxy requests through in any sort of real environment. And if you're not in production...well, it doesn't really matter which port you choose anyway.
- trebor 14y agoVery true. This will also let you run multiple instances of node and do load balancing.
- parasight 14y agoPlease excuse my ignorance, but why would I want to run nginx to proxy requests through?
- onewland 14y ago[This response is a guess, and very generalized] You probably won't handle every HTTP edge case as well as nginx defaults, and you don't really need the control at that level to implement a functional, high performance web app.
- javis 14y agoPossibly because Nginx serves static content much faster than Node.
- cparedes 14y agoThe reasons that other folks have mentioned (static files, nginx is built for lots of HTTP requests), as well as basic load balancing between several 'worker processes'. Sometimes you'll want to have several app server processes running with several ports open, and have nginx load balance between all of those processes (then load balance again at a higher tier between all of the different nginx processes.)
- Wintamute 14y agoIf you're running a few services and sites on the same box you need some sort of proxy listening on port 80 reverse proxying incoming requests to the correct internal port. i.e. an incoming request looking for "www.mynodeapi.com" could be internally routed to "127.0.0.1:8080" (or wherever your node app is listening). The proxy could be nginx, haproxy or perhaps even a node app using node-http-proxy. AFAIK, if you need proper web sockets support your proxy has to be node based or haproxy.
- m0th87 14y agoUnless you want websocket support. Then it gets a little more complicated: http://stackoverflow.com/questions/10329281/nginx-1-2-0-socket-io-http-1-1-proxy-websocket-connections http://stackoverflow.com/questions/10329281/nginx-1-2-0-sock...
- jeromeparadis 14y agoHAProxy works Wellington for node.js websocket apps.
- Pewpewarrows 14y agoAfaik, Disqus uses websockets with Nginx fine. I believe they recently mentioned writing and using this module: https://github.com/wandenberg/nginx-push-stream-module https://github.com/wandenberg/nginx-push-stream-module
- jaytaylor 14y agoOr better yet, use HAProxy [1] instead of nginx. [1] http://haproxy.1wt.eu http://haproxy.1wt.eu