Nginx and Nodejs How to use?

Posted June 5, 2017 48.7k views

I see hello world!

I would like my domain name to be pointed to var/www/html so I can run

IPB software and Nodejs as back up as some of the apps in my IPB uses nodejs.

This reverse proxy setup is flexible enough to provide your users access to other applications or static web content that you want to share.

How do I switch between the two and were is my static web content folder?
How do I point my domain so it loads the static web content from my folder?
WIll this effect my nodejs apps which are needed from my web board IPB?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @peopleandchat

You can follow this tutorial to setup Node.js with Nginx as proxy - or did I misunderstand your question?

by Brennen Bearnes
Node.js is an open source JavaScript runtime environment for easily building server-side and networking applications. Node.js applications can be run at the command line but this guide focuses on running them as a service using PM2, so that they will automatically restart on reboot or failure, and can safely be used in a production environment.

My questions were not clear and sorry for that. I run LEMP server and now Nodejs on it. I have eveything set up and see it say hello world!

Were in the proxy do I set up a static web content so I can run wordpress and run nodejs apps on side folders of nginx?

  • @peopleandchat

    So if WordPress is already setup and running, then you can add the following to your Nginx server block configuration to run your Node.js app in a sub-folder (I’m going to put it in /myNodeApp and expecting Node.js is listening on port 8080) and restart Nginx:

        location /myNodeApp {
            proxy_pass http://localhost:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;

    It’s actually more or less what the tutorial explains, but it all depends on if you’re already setup WordPress or not. If you need further help, it would be easier if you paste you Nginx server block configuration here (use the </> button in the comment editor to wrap it like code)