Nginx Proxy

I raised a virtual server on Ubuntu 18 and performed the installation according to the instructions https://docs.n8n.io/#/server-setup

Now I want to perform proxying from the main server to the local server and I can’t do it. If I open the site at http://localhost:5678/workflow then everything works, just on the internal IP address http://192.168.0.1:5678/workflow
I made a proxy but I don’t understand why it doesn’t work
location / {
proxy_pass http://192.168.0.1:80;
proxy_redirect http://192.168.0.1:80 /;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

I am now getting a 502 error

location / {
proxy_pass http://192.168.0.106:5678;
proxy_set_header Connection ‘’;
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}

Log: 111: Connection refused

Very sorry, but do not understand what exactly you are trying to do. Can you please explain what you have planned and why.

  1. I have 2 VMS and 1 static IP address
    2.1. The first virtual machine with hosting, here is a static IP address
    2.2. On the second one, I installed ubuntu server 18 and installed n8n according to the instructions. https://docs.n8n.io/#/server-setup
  2. When I enter the internal IP on n8n, example: 192.168.0.101:5678 - everything opens correctly
  3. Now I want to do nginx proxying to the n8n server (the second VM inside the network)
  4. I have registered the following configuration:

location / {
proxy_pass http://192.168.0.101:5678/;
proxy_set_header Connection ‘’;
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
}

It is correct, but error 502 is shown instead of the service.
I see this error in nginx Logs. Error 111: Connection refused
I can’t figure out what I’m doing wrong.

In other words I created a subdomain in the first VM n8n.mysite.ru and installed proxying on the second virtual machine.

Still, a little bit confused about what exactly is happening but even if I would fully understand it, I would sadly still be unable to help you here. The reason is simple. Even though I would love to help you, I can sadly not as my Nginx knowledge is more than limited and the problem you are having seems to be Nginx-setup related.
I can just tell you that for me it also looks correct assuming that the IP is correct and what you posted is only part of your setup. So that you have above you also “server” defined with the ports like in this example:

If all that is the case I am sadly also lost. I would probably check with some Nginx people what they think could be going wrong.

I raised n8n on the same server where my hosting is located. I disabled traffic and used nginx instead.

Everything is working now.

1 Like