N8N - using a different context path

Information on n8n setup

  • n8n version: 0.178.0
  • Database: Postgres
  • Running n8n via npm on Windows 2019 Server

My goal

I am retrying to setup multiple n8n instances on a single host. In addition a ssl reverse proxy should provide the SSL termination, e.g.

SSL reverse Proxy (https://www.example.com)
 |
 |--- N8N Instance 1 (https://www.example.com/n8n_default)
 |--- N8N Instance 2 (https://www.example.com/n8n_instance2)
 |--- N8N Instance 3 (https://www.example.com/n8n_instance3)

Challenge 1: Run multiple N8N instances on same host

  • Seems to work by setting the USERDIR variable to a dedicated value for each instance, providing a different port via N8N_PORT and using dedicated db schemas.

Challenge 2: Use different context path for each instance (but not yet using a SSL proxy)

  • I tried the solution mentioned here N8N as a subfolder with nginx - #5 by harshil1712, but without any success.
  • N8N is starting fine, the js/css resources in the returned html page pointing to “/n8n_default” (as expected), but N8N is still serving css and js resources using “/” as path
      "N8N_PORT" : 6678, 
      "N8N_PATH" : "/n8n_default/",
      "DOMAIN_NAME" : "localhost",
      "WEBHOOK_URL" : "http://localhost:6678/n8n_default",
      "VUE_APP_URL_BASE_API" : "http://localhost:6678/n8n_default",
<!DOCTYPE html><html lang="en">
<head><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" href="/n8n_default/favicon.ico">
<script>window.BASE_PATH = "/n8n_default/";</script>
<title>n8n.io - Workflow Automation</title><link href="/n8n_default/js/chunk-2d2073c1.f0370751.js" rel="prefetch">
<link href="/n8n_default/js/chunk-2d22d3e6.388c0a4c.js" rel="prefetch"><link href="/n8n_default/js/chunk-4301fce8.d032a636.js" rel="prefetch"><link href="/n8n_default/js/chunk-b1e1f7c0.92d036f0.js" rel="prefetch"><link href="/n8n_default/css/app.3544aae5.css" rel="preload" as="style"><link href="/n8n_default/css/chunk-vendors.274eb558.css" rel="preload" as="style"><link href="/n8n_default/js/app.98057e67.js" rel="preload" as="script"><link href="/n8n_default/js/chunk-vendors.ec9c98e5.js" rel="preload" as="script"><link href="/n8n_default/css/chunk-vendors.274eb558.css" rel="stylesheet"><link href="/n8n_default/css/app.3544aae5.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but the n8n Editor-UI doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/n8n_default/js/chunk-vendors.ec9c98e5.js"></script><script src="/n8n_default/js/app.98057e67.js"></script></body></html>

Any ideas which additional setting I should tweak ?


Challenge 3: Wrap the stuff using a reverse proxy

  • Not yet started, but I guess I will observe more suprises :frowning:
1 Like

Hi @aschuma, welcome to the community and I am sorry to hear you’re having trouble here.

The documentation for VUE_APP_URL_BASE_API suggests this variable is only taken into account when building n8n:

Used when building the n8n-editor-ui package manually to set how the frontend can reach the backend API.

So you might need to build a custom version of n8n as described here. Tbh, this seems like like a lot of effort, especially when keeping these up to date.

So it seems much simpler to set up individual subdomains for each of your n8n instances (your third option) and just use the default path / for each (at least with nginx or caddy as the reverse proxy). Seeing you are using Windows Server make sure to check out this configuration advice from fellow community member @lublak if you want to use IIS:

Hi MutedJam

Thank you for the valuable answer.

I thought already about using subdomains for the dedicated N8N instances. But in this special case I probably run into trouble to get dedicated certs or wildcard certificates. This is an other story :frowning:

What I do not get is, why it’s possible to specify an N8N_PATH at all? In general I would assume, that this would change the context path globally. Probably I missed something in the doc. Could you clarify that?

Best wishes

The idea is to run this behind a reverse proxy server, you can find some more background from our development team here on this GH issue:

Hi @MutedJam ,

I’m also trying to move n8n to a subfolder. I set up the environment variable VUE_APP_URL_BASE_API, install, build and start n8n but I get:

Do you have any advice? Thank you in advance!

Hey @valya,

Can you share your config so we can take more of a look? A 404 is fairly generic so it is going to come down to your config.