Max Girkens,
In the last days, i was trying to find a solution hosting multiple
Express apps on
my vServer the same Server.
Starting with
Apache and
mod_proxy, i ended up with a plain node solution, which i really like.
Let’s take a quick look on some different approaches out there:
—1—
Using apache on port 80 as a proxy
1 | ProxyPass /nodeurls/ http://localhost:9000/ |
2 | ProxyPassReverse /nodeurls/ http://localhost:9000/ |
via
stackoverflow
— no websockets
++ probably the easiest way to integrate with your running AMPP-stack
—2—
Using a node.js app on port 80 as a Wrapper for other node apps.
2 | .use(express.vhost( 'hostname1.com' , require( '/path/to/hostname1' ).app) |
3 | .use(express.vhost( 'hostname2.com' , require( '/path/to/hostname2' ).app) |
via
stackoverflow
++ you can use websockets on port 80
— apps crash/restart/stop globally
–what about your apache or the like?
—3—
Using node.js with node-http-proxy on port 80
1 | var http = require( 'http' ) |
2 | , httpProxy = require( 'http-proxy' ); |
4 | httpProxy.createServer({ |
8 | 'www.my-domain.com' : '127.0.0.1:3001' , |
9 | 'www.my-other-domain.de' : '127.0.0.1:3002' |
++ proxy websockets to any port
— you might need to move your old web server to another port
The really cool thing about using node-http-proxy is its capability of proxying websockets.
So you can have your apps running independtly on different ports while
serving everything to the user over port 80 and use stuff like
socket.io.
Since i’m new to node.js and miles away from beeing a admin, any feedback is highly appreciated :)
Comments
Post a Comment