N8n hosting set up on Digital Ocean

Hi,

we keep all our infrastructure in the cloud with Digital Ocean and to optimize costs, we would like to host n8n there as well.

However, when trying to create a droplet and follow the steps given in the n8n documentation, I have not been able to make it work. This is the second time I have created a subdomain and droplet, but in both cases, although the installation is successful without errors, I cannot access the domain. The first attempt was yesterday, and the second one was this morning.

Can you help me understand what I might be doing wrong?

Here is the step-by-step I performed:

1. Install Docker
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

3. Install Docker-Compose#
sudo apt-get install docker-compose-plugin

Digital Ocean - n8n Documentation

Clone configuration repository
git clone https://github.com/n8n-io/n8n-docker-caddy.git
cd n8n-docker-caddy

Create Docker volume
docker volume create caddy_data

Open ports
sudo ufw allow 80
sudo ufw allow 443

Configure n8n
nano .env

The Docker Compose file
nano docker-compose.yml

Configure Caddy
nano caddy_config/Caddyfile

Start Docker Compose
docker compose up -d

Here are the sources:
Docker Compose - n8n Documentation

Digital Ocean - n8n Documentation

Here is my subdomain:
n8n.felipewelington.com.br

Here is DNS checker:
DNS Checker - DNS Check Propagation Tool

Hey @Lara_Bertini,

Looking at the links you provided it looks like the n8n subdomain has not been set up on your domain.

Just to double check did you add the A record in the DNS settings for your domain?

I think I did, but below is a printout of the configuration in turbocloud.

Do you think I missed something?

Hey @Lara_Bertini,

I am not sure what Turbocloud is, is that what managed the DNS for your domain? I did quick domain lookup and it looks like the site is using Cloudflare for DNS so I would expect the A record to be added there.

Hi @Jon! Thanks for you help!

We use TurboCloud as our website hosting provider, and Cloudflare as our Content Delivery Network (CDN) service. As the CDN works by mediating the connection flow to our site, we had to create a subdomain there and add SSL. However, despite several attempts, we were unable to get it to work. It was only after turning off Cloudflare that we were able to see the n8n login screen.

However, upon testing our workflows, we found that n8n was functioning unpredictably. For instance, it would read the webhook at times, and at other times it would not. We are uncertain how to proceed from here.

Hey @Lara_Bertini,

That makes sense as the DNS is handled by Cloudflare or at least the nameservers for your domain were pointing there.

When you say it would read the webhook at times what do you mean? Does the request fail when sending the request or do you see no message at all?

I simulate the http POST using reqbin and the following code:

curl -X POST https://popular-otter-26.hooks.n8n.cloud/webhook-test/b5a4fe9f-7eab-4b52-88e8-63afffb252cf
   -H 'Content-Type: application/json'
   -d '[
    	{
        "name": "Cynara",
        "email": "[email protected]",
        "data":"2023-04-09T16:04:52.396Z",
        "phone":"5585997994334",
        "expert":"Giovane",
        "description":"Aplicação 1",
        "origin":"Highticket",
        "way":"Formulário",
        "retribution":"Interesse",
        "action":"Preencher",
        "situation":"Perdido",
        "public":"xxxxxxxxxxx",
        "funnelProduct":"xxxxxxxxxxx",
        "utmSource":"xxxxxxxxxxx",
        "utmId":"xxxxxxxxxxx",
        "utmTerm":"xxxxxxxxxxx",
        "utmCampaign":"xxxxxxxxxxx",
        "utmMedium":"xxxxxxxxxxx",
        "utmContent":"xxxxxxxxxxx"
    }
]'

The http post request is sent successfully. But the webhook in n8n cloud listened two days ago. One day ago, after several attempts one in one time it successfully listened the request.

Now I´m wondering if this instability has something to do with the DNS…

By the way, this same exercise works fine in n8n destop version…

Looking at that you are using the webhook-test endpoint which could be part of the problem but you are also using the tunnel option instead of the webhook_url to use your own domain so there could also be something there.

It might be worth taking another look at your configuration and environment to make sure everything is correctly configured.

@Jon , thank you for helping me once again :). But I must confess I got a little confused with your answer. As far as I understand, I’m using the webhook test link instead of a tunnel service. I would like to understand how you came to the conclusion that I could be using a tunnel service.

And regarding your suggestion of taking another look at my configuration and environment, how can I make sure that the settings are correct? What would you check?

Hi @Lara_Bertini

He noticed the name which shows there is probably a tunnel to n8n cloud. :wink:

I’m sorry I have more questions, I really appreciate the fact that you’re helping me.

During the n8n hosting configuration process on Digital Ocean, I ran the following commands:

Open ports
sudo ufw allow 80
sudo ufw allow 443

Wouldn’t these commands be responsible for making my n8n instance on Digital Ocean accessible over the Internet?

Furthermore, I understand that Digital Ocean is a public cloud hosting service provider, which means that the instances I create are accessible over the internet, right? That’s why I’m confused when you say I may be using tunnel services.

@Jon @BramKn I noticed that when I copy the n8n desktop workflow to the n8n hosted on Digital Ocean, the webhook doesn’t listen to my HTTP request (simulated through reqbin) the way it should. In addition, when I try to click on the stop listening button, it doesn’t work. It seems to be unresponsive.

Maybe the issue is not with my hosting settings but with using nodes copied from my n8n desktop. Does this hypothesis make sense? Would this have something to do with the tunnel connection you´ve mentioned when looking at the links I was using?

Here is my workflow:

Here is the reqbin code I´m using to generate the http post request after coping the workflow from n8n desktop to my hosted app in Digital Ocean, and replacing the webhook node:

curl -X POST https://n8n.felipewelington.com.br/webhook-test/0989e0f7-e7a3-4854-87a9-3724f5945b4e
   -H 'Content-Type: application/json'
   -d '[
    	{
        "email": "[email protected]",
        "data":"2023-04-09T16:04:52.396Z",
        "expert":"Giovane Saraiva",
        "description":"Aplicação 1",
        "origin":"Highticket",
        "way":"Formulário",
        "retribution":"Interesse",
        "action":"Preencher",
        "situation":"Perdido",
        "public":"xxxxxxxxxxx",
        "funnelProduct":"xxxxxxxxxxx",
        "utmSource":"xxxxxxxxxxx",
        "utmId":"xxxxxxxxxxx",
        "utmTerm":"xxxxxxxxxxx",
        "utmCampaign":"xxxxxxxxxxx",
        "utmMedium":"xxxxxxxxxxx",
        "utmContent":"xxxxxxxxxxx"
    }
]'

Even after replacing the webhook node that came from the copied code from n8n Desktop with a new node from the n8n hosted on Digital Ocean itself, the workflow still doesn’t work. For some reason, the new webhook is still not listening to the HTTP post I made through reqbin.

Hey @Lara_Bertini,

There is a lot to go through there but the quick version is the first url you were showing that has n8n.cloud in it normally comes from the tunnel, As you have been using desktop it is possible that wrong url was shared.

Workflow data is just json and doesn’t contain the url that is automatically generated from the webhook_url env option if set.

I think there is a lot of confusion here around the environment itself and what each part does, the ufw commands would open the firewall ports and allow access but it doesn’t control the domain itself.

In theory accessing the droplet using the IP should result in a certificate error and allow you to at least see if it is running. It does look like it is available now which is good so it could just be if the workflow is active or not or the method being used in the webhook node.

When you run the curl command what is the output?

Got it! The output of the HTTP POST is always successful, however, sometimes the webhook reads it and sometimes it doesn’t.

Perfect, when it fails is that when using the test url or the production one?

@Jon – The testing one.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.