简体   繁体   中英

How to check that NodeJS script is running on Nginx server

I'm trying to configure nodejs + nginx. I've installed nginx and created one express app. I've configured almost everything with the bless of google and gist, and after doing all these things I want make sure that node script is running on nginx. I'm asking such because I started my node server by saying "node app.js" and I've defined my ip add in nginx conf file ( /etc/nginx/sites-enabled/default ). Again node is running server and nginx is also a server how come both work together ?

nginx is another server which should stay before node server. Node should generate all dynamic content and nginx will serve static files.

So Yes they are separate servers and scripts are run by node.

You are using ngnix just for proxying and caching the static files and setting the approprite expire headers.. but the files are served from Express server itself.

Again node is running server and nginx is also a server how come both work together ?

Yes they both are web servers which can receive and interpret the HTTP requests, In this case your requests are handled by Nodejs and nginx is acting as a just proxy server.

Note:

If you want to serve the static files from nginx, you need to set the root inside your location config.

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