I have a domain set up, and a website that runs properly on it currently.
I want to add a subdomain which will run a Node.js server to server as an API.
Here are the things I tried so far:
If anyone could provide me with the exact steps needed to set this up, I’d appreciate. I have wasted three days on this so far…
I am not a backend developer or a dev ops person, so please do not use unclear terms, or expect any previous knowledge.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
First, thanks for the elaborate answer.
There were quite a few snags here:
/etc/nginx/sites-available, and I don’t know what combination to use. I tried so many, and even DigitalOcean’s generator (which creates a super long config file with WAY too many options that I don’t understand)I tried to make sense of the Jenkins article you shared (what’s a proxy? what’s a reverse proxy?), there are too many terms that are out of my domain, that I honestly give up. I will try and hire someone to fix this, it will be less expensive than me trying to figure the magical config this expects.
Thanks for the time you took, and your respectful tone. 🙏
Hi @jansensan,
Let’s start with the things you mentioned first.
Okay, now that your questions are answered, let’s get into how you can make your application work!
Usually, NodeJS applications are using ports like 8081, 8080 and so on. However what happens if you want to use more than one application on the same droplet? Well, you need to install a service that creates proxy requests. By default when you open a website, it loads on port 80 for http and 443 for https. The Nginx service can take these requests and by the use of a configuration file redirect the request to the port your application is running on.
In that regard, If you don’t have Nginx installed, that would be the first thing to do. If you are unsure how to do so, DigitalOcean has a pretty good tutorial about this:
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04
Once you have Nginx installed you’ll need to setup your configuration files to work as a reverse proxy. Again, DigitalOcean has a pretty good tutorial on that front as well:
Yes, it’s for Jenkins but you can replace the bits where it’s mentioned Jenkins with your Application.
Regards, KFSys
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.