简体   繁体   中英

Deploy MEANJS app production

I'm having a demo this coming week and I need to deploy the application I'm working on (developed using MEANjs stack) preferably to a server like nginx or the like.
I'm behind a Red-hat box so my question is what would be the best practices when deploying an application to production

  • Does a deploy to nginx is viable? (redhat box has already installed apache, do I need to interchange with nginx?)
  • is there any notes on what to and not to do for this process?

I've found this How to deploy MEAN.js (Node.js) application to Production environment

and I was trying to comment but don't have the required points :D so anyway, don't quite understand the nginx part(putting in front) so that means that you don't actually deploy the app into nginx ?

I've also look at other questions like:

so its like do we really need ningx, apache or the like from the best practices perspective?, or the way to go is just rsync the content to a production server folder and start your app with Upstart?

what about using Passenger with MEANjs anyone used this?

EDIT:

Alright so I have my meanjs server running on port 8002 below is my configuration for ningx, which is working as far as I can tell allright, now what about securing this setup?

EDIT2: Well I'm learning here so this is what I found https://groups.google.com/forum/#!topic/meanjs/_Kb07-tvlzU
apparently in order to deploy this after running the "grunt build" command just run it like so :

node server.js

and apparently it will get all your configuration from production.js
Not completely sure if it would be production ready.
and now I think I should move this to somewhere like /var/www/theAppFolder/ for organizational sake.

this is nginx configuration

upstream proj{
  server 127.0.0.1:8002;
}

server{
  listen 0.0.0.0:80;
    server_name dep01.local  poc;
    access_log /var/log/nginx/dep01.log;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;

      proxy_pass http://proj/;
      proxy_redirect off;
    }
}

Deploying your node app behind nginx is definitely viable.

Your red hat box is ok to host birth servers.

You need to install both node and nginx to the server.

Then deploy node app so it listens to some high port, say 8000. You also setup your app to trust it's proxy (which is what nginx will do). For security reasons, you can only slow connections to the node port from localhost.

Now go on and configure nginx.You can, for example, set an "upstream" in the config to point to localhost:8000. Then stop a virtual host in nginx conf for your app and domain and proxy requests to the previously defined upstream.

You can smash set any SSL certificates on nginx, that way i it will be more performant (node tends to be much slower then nginx with SSL).

alternatively, you can just bind node directly to port 80 (and 443 for SSL) and skip using nginx, but that depends on the server, the app, the audience and environment and your personal preferences and experiences.

For details about any of the steps, try providing more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM