Question

Is it possible to serve multiple dynamic websites from one Ubuntu 20.04 droplet?

And if yes, are there any good tutorials that show me how?

Context: Using a single DO droplet, I want to serve up multiple domain names, each with their own dynamic content written in different server side frameworks (i.e. example1.com is written with Node.js and example2.com is written with .NET Core). I’m wondering if this is possible.

From research, I’ve found that it is possible to serve multiple static websites using virtual hosts in Apache (or server blocks in Nginx). However I can’t tell if the same applies to dynamic websites, nor how I’d accomplish that.

FYI, I tried using a Docker droplet with virtual hosts to serve multiple websites with dynamic content, but this is cumbersome to update. For some reason, when updating my websites I need to completely rename and rebuild the Docker image. I want to move away from that infrastructure.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Hello @zzork

You can serve multiple websites from a droplet (whether they’re static or dynamic). You can use the tutorial on how to serve multiple static websites using virtual hosts in Apache (or server blocks in Nginx) as a reference.

The tutorial mentioned by KFC is perfect on how to setup a node.js application.

Regards

Hi @zzork,

Yes, it’s possible. all you need to do is make them listen on different ports and then use a reverse proxy like Nginx to configure it to rewrite traffic from ports 80 and 443 to the proper port. Let’s take Nginx for example, check this tutorial on how to configure it:

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-20-04#step-4-setting-up-nginx-as-a-reverse-proxy-server

Configuring the Nginx Proxy would be pretty much the same with the difference here:

server {
...
    location / {
        proxy_pass http://localhost:3000;
        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;
    }
...
}

The proxy_pass in this case is using port 3000, you can create more than one Nginx config for your websites/apps and use different ports depending on what’s needed.