Question

Running Droplet with Python Flask and NodeJS

Posted April 5, 2021 957 views
Node.jsPythonJavaScriptFlask

Hello all,

I am currently running a droplet with a Python Flask app, using Nginx. I am looking to add a NodeJS app to the droplet for a frontend. Is there any pitfalls to me doing this? I am relatively new to this side of computing, and am unsure of the best processes to follow.

I am also mostly unfamiliar with NodeJS, so I don’t know how the interactions work. Also is it possible to run two NodeJS apps together on one droplet? In the future I’d like to add another NodeJS app.

Thanks for any help and advice!

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

Hey @RizLord,

Shouldn’t be a problem at all.
Just make sure you run your node.js applications on different ports.

Use NGINX proxying functionality to point different routes to different ports.

Here’s an example:

location /route {
    proxy_pass  http://127.0.0.1:9999/;
}

Where 9999 is your node.js port.

Hi @RizLord,

There won’t be any issues, I can confirm this as this is something I’ve tried many many times. You can have as many and different apps as you won’t as long as you use free ports on your server for them.

Additionally, if you are already using Nginx, you can configure it as a reverse proxy for your App to the NodeJS’s port.

All in all, you are 70% complete with Nginx, you just need to configure NodeJS and your Nginx configuration to be used as a reverse proxy. You can take pointers from this tutorial:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

Regards,
KFSys

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.