N8n behind NGINX reverse proxy

Describe the problem/error/question

I did install n8n on an UBUNTU system. n8n does run under http://localhost:5678 .

In front of it I use NGINX as a reverse proxy which can be reached under https://my_domain .

Login to the n8n installation does work and I am able to create workflows.

This is the server block setting in the configuration of the n8n site:

    location / {
            proxy_pass http://localhost:5678/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Port 443;
            proxy_redirect off;
            proxy_set_header Connection "upgrade";
            proxy_set_header Upgrade $http_upgrade;
    }

I did set the environment variables as follows:

   N8N_HOST=0.0.0.0 
   N8N_PORT=5678
   N8N_PROTOCOL=HTTP
   WEBHOOK_URL=https://my_domain/

I added a Telegram trigger in a new workflow to start with.

The automatically created Webhook Url does look like this:

   http://localhost:5678/webhook-test/f840ce7c-8d25-41cb-bdff-1ae2b47dcc69/webhook

What is the error message (if any)?

When I try to execute the step I receive this error message:

  ## Problem running workflow

  *Bad request - please check your parameters*

  Show Details

  Telegram Trigger: Bad Request: bad webhook: An HTTPS URL must be provided for webhook

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.98.1
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: UBUNTU Ubuntu 22.04.5 LTS
1 Like

Hi @Nadir hope all is well, welcome to the community.

Did you read this Configure webhook URLs with reverse proxy | n8n Docs ?

@Nadir

If you’ve set
WEBHOOK_URL=https://my_domain/

With ure actual domain name, the urls in the nodes inside of n8n will change to whats set.

Remember you will need to redeploy or apply within the container and restart N8n for changes to take effect.

Samuel

I did setup the environment variable WEBHOOK_URL .

But the Webhooks didn’t change … that is the problem

No docker installation … I installed with npm

Can you change N8N host also, to domain name. I would give the server a restart after too.

Also am not sure if it would conflict, but change to https N8N_PROTOCOL

N8N_HOST changed to domain name … Server rebooted … no change

Webhook is still http://localhost

I think I have an idea what the problem might be.

I do use PM2 to run n8n as a service. It assume that the environment variables might not get passed to the service. I will investigate.

Yes … that was the problem. After a restart of n8n via

sudo pm2 restart n8n --update-env

the webhooks did change and now the trigger does work.

1 Like

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