Two domains on one droplet: static website and node app. Only showing one!

I need some help setting up multiple domains on one digital ocean droplet. I have one node.js application running on my droplet. This one is working fine. I have now tried to add another (static) website with another domain to this droplet, by following the following two tutorials:

Unfortunately, when trying to access the second domain in the browser, it shows the node application I first set up. There is a problem with linking the right website files to the second domain. I have the feeling it might be to do with my root folder (or the path to it), as I did not exactly follow the defaults in the tutorial.

My sites-enabled files look like this at the moment:

The Node application:

server {

        listen 80;

        root /home/Bas/node-application;
        index index.html index.htm;

        return 301 https://$server_name$request_uri;

server {
        listen 443 ssl http2;
        ssl_certificate /etc/letsencrypt/live/$
        ssl_certificate_key /etc/letsencrypt/live/$

        # Include  the SSL configuration from
        include /etc/nginx/snippets/ssl-params.conf;

        location / {
           proxy_pass http://localhost:3001;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-NginX-Proxy true;
           proxy_ssl_session_reuse off;
           proxy_set_header Host $http_host;
           proxy_cache_bypass $http_upgrade;
           proxy_redirect off;
        location ~ /.well-known {
                allow all;

The new website, which I would like to add, but is currently not linked to the domain:

server {
        # Enable HTTP/2
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /home/Bas/domain2;
        index index.html index.htm;

        return 301 https://$server_name$request_uri;

        location / {
            try_files $uri $uri/ =404;

I have read a lot of questions on the forum, but can’t find the answer to this specific one. Any help would be much appreciated!

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.

Accepted Answer

Hi @basmariot

But your second code snippet is redirecting to https, so if you haven’t got a configuration block for domain2’s https, then Nginx will serve the first https server block. This is a known Nginx “feature”:

Just remove the return-line or create the https block for domain2 - that should fix it.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel