I am reading more than ever at this time, this will be my first web page, so I decided to mount on nodejs. I make the application really fast and I am testing in localhost: 9000
so I want to add more applications on VPS, I'm looking for information and I have two options
first use nginx to proxy applications ...
upstream example1.com { server 127.0.0.1:3000; } server { listen 80; server_name www.example1.com; rewrite ^/(.*) http://example1.com/$1 permanent; }
I do not understand this configuration file because I never use nginx, so I am looking for the second option
using vhost from expressjs ()
express() .use(express.vhost('m.mysite.com', require('/path/to/m').app)) .use(express.vhost('sync.mysite.com', require('/path/to/sync').app)) .listen(80)
im using expressjs, and I understand how to configure, but there are some questions about which one is the best option, because with express () I have one application that manages multiple applications, so I believe that this is not good practice and a waste of resources.
from this post, David Ellis says
If you don't need to use WebSockets (or any HTTP 1.1 feature), you can use NginX as a proxy instead.
The advantage is that the overall load that NginX can handle compared to Node is higher (it statically compiles and specializes for these kinds of things, mostly), but you lose the ability to transfer any data (sending smaller chunks at a time).
For a small site, or if you don't know what features you will need in the future, it's probably best to stick with node-http-proxy and only switch to NginX if you can demonstrate a proxy server bottleneck on your server. Fortunately, NginX is not difficult to configure if you need it later.
and this post I read an example of xginx setup with many applications, but I donโt understand how to use this for me
upstream example1.com { server 127.0.0.1:3000; } server { listen 80; server_name www.example1.com; rewrite ^/(.*) http://example1.com/$1 permanent; }
so the question is the best option, use nginx or use vhost ???
if I need to use nginx, is there some kind of tutorial on how to configure nginx to serve many applications on Node js ???
tnx all