We’ve been evaluating n8n for our team (internal use, no monetary gain) and think it’s going to be a fantastic fit for us. We’ve developed a node to leverage z/OSMF APIs (IBM Mainframe) to automate manual work. Since only a small subset of our team is familiar with the technology required to get n8n running, we were hoping to simplify the “barriers of entry” to get n8n available for each member our team.
For us, the ideal environment would be the following:
One Server running Docker
One Docker Container running Nginx
Many Docker Containers running n8n (one per user)
The Nginx configuration would have multiple proxy_pass statements for each user:
User1 would go to example.com/user1 and be connected to their instance, User2 would go to example.com/user2 and be connected to their instance, and so on.
I’m definitely oversimplifying the configuration/structure for discussion purposes but unfortunately we cannot get n8n working in this kind of environment. No matter what combination of Nginx configuration/n8n environment variables we try, we cannot get n8n to work properly.
Has anyone successfully set up a multi-user environment like this or possibly provide some advice on the proper configuration details to get this working?
Appreciate any and all advice/feedback. Thank you so much!
Thank you @jan! Following the n8n server setup URL above helped with setting up multiple instances, each with their own URL. For now, this will do. We might revisit to see what needs to be done if we want the same URL but a different URI (example.com/user1, example.com/user2, etc.) but that’s a stretch goal at this point. I’ll mark this complete. Thanks again!
@Ian_Taggart Can you share how to install on sub folder like you’ve done? I’ve install on subdomain n8n.example.com successfully, now I want to install on multi subfolder like this: n8n.example.com/user1, n8n.example.com/user2… but not successful, when install, it shows error like this
[email protected]:~/n8n/0680# sudo docker-compose up -d
Creating network "0680_default" with the default driver
Creating 0680_n8n_1 ...
Creating 0680_n8n_1 ... error
WARNING: Host is already in use by another container
ERROR: for 0680_n8n_1 Cannot start service n8n: driver failed programming external connectivity on endpoint 0680_n8n_1 (0b6bddaa755ea252aaff35efea33b5e56654df87fc83b74e3e343c2a1d231e49): Bind for 127.0.0.1:5678 failed: port is already allocated
Creating 0680_traefik_1 ... error
ERROR: for 0680_traefik_1 Cannot start service traefik: driver failed programming external connectivity on endpoint 0680_traefik_1 (2947261f7ac88b9c2d3b3fd217d03ad3f8ba5a75765bb9823c775d6a3e52e5cb): Bind for 0.0.0.0:443 failed: port is already allocated
ERROR: for n8n Cannot start service n8n: driver failed programming external connectivity on endpoint 0680_n8n_1 (0b6bddaa755ea252aaff35efea33b5e56654df87fc83b74e3e343c2a1d231e49): Bind for 127.0.0.1:5678 failed: port is already allocated
ERROR: for traefik Cannot start service traefik: driver failed programming external connectivity on endpoint 0680_traefik_1 (2947261f7ac88b9c2d3b3fd217d03ad3f8ba5a75765bb9823c775d6a3e52e5cb): Bind for 0.0.0.0:443 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
[email protected]:~/n8n/0680# sudo docker-compose up -d
Starting 0680_traefik_1 ...
Starting 0680_traefik_1 ... error
WARNING: Host is already in use by another container
ERROR: for 0680_traefik_1 Cannot start service traefik: driver failed programming external connectivity on endpoint 0680_traefik_1 (2dcf303d7bca44e5cf84bf1606182b8d022e78d645dcc180f6bada4e8c331d0c): Bind for 0.0.0.0:443 failed: port is already allocated
Recreating 0680_n8n_1 ... error
ERROR: for 0680_n8n_1 Cannot start service n8n: driver failed programming external connectivity on endpoint 0680_n8n_1 (d114ca17ffb45285b3ac93a8ee8e4f6765fc5b337af2fadbbfea440b7975e47d): Bind for 127.0.0.1:5678 failed: port is already allocated
ERROR: for traefik Cannot start service traefik: driver failed programming external connectivity on endpoint 0680_traefik_1 (2dcf303d7bca44e5cf84bf1606182b8d022e78d645dcc180f6bada4e8c331d0c): Bind for 0.0.0.0:443 failed: port is already allocated
ERROR: for n8n Cannot start service n8n: driver failed programming external connectivity on endpoint 0680_n8n_1 (d114ca17ffb45285b3ac93a8ee8e4f6765fc5b337af2fadbbfea440b7975e47d): Bind for 127.0.0.1:5678 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
Hi @huuich, sorry for the confusion here! I was not actually able to figure out how to host multiple n8n instances from one URL with “subfolders” as you described above. It seems as though n8n is trying to use relative paths when loading the various html files so they never try and look for it in the right location. We had to spin up individual n8n instances in individual ec2 servers, each with their own URL in order for it to work correctly. Multiple n8n instances under one URL is definitely something that we want as well but cannot figure it out so we did this as a workaround until we do.
but when I visit IP:443 it shows 404 Page Not Found.
Also tried visiting Port 80, 5678 but dont know where the n8n is running.
Also checked with docker image ls
[email protected]:~/n8n/docker/compose/subfolderWithSSL$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
n8nio/n8n latest d4b87c6f9d89 4 days ago 359MB
traefik latest c6e6fde07226 11 days ago 78.4MB
I just checked. For some reason did WEBHOOK_TUNNEL_URL and VUE_APP_URL_BASE_API use http instead of https. Fixed that now. Apart from that did it look OK on the first sight.
One thing you wrote was: but when I visit IP:443 it shows 404 Page Not Found.
You have to make sure to not visit “IP:443” you have to visit your configured domain with subfolder. So for example: https://example.com/n8n
Thanks, currently the n8n is working on the given subfolder, for the first time. but how do we create multiple instances ? I tried creating another subfolder in it but didnt work. Could you let me know what path should the subfolders should be created and what should it contain.
If you need different ones you would have to copy the “n8n” part of the docker-compose file multiple times. But then make sure that you rename it and that you then best hard-code all the variables like N8N_PATH/SUBFOLDER, everything authentication related, … (so everything which should not be the same between the deployments).
When I did docker-compose up -d it ran without any error but when I open the path in browser it shows
404 Page not found.
Even the app1 subfolder page which was working earlier didnt work after adding this. I had changed the ports of n8n2 but when I ran docker-compose ps it shows this
[email protected]:~/n8n/docker/compose/subfolderWithSSL$ docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------------------------------
subfolderwithssl_n8n2_1 tini -- /docker-entrypoint.sh Up 127.0.0.1:5676->5676/tcp, 5678/tcp
subfolderwithssl_n8n_1 tini -- /docker-entrypoint.sh Up 127.0.0.1:5678->5678/tcp
subfolderwithssl_traefik_1 /entrypoint.sh --api=true ... Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
In the n8n2 it still shows port 5678, is it because of that ?
Hi, sorry for the accidental tag - please see above for my edit and info.
So yes, we were able to get it working within a controlled environment but we don’t have the ability to reach out to LetsEncrypt so we had to remove all of the labels related to SSL. But we did get it to work! We experienced the same issues that you did when moving from one n8n instance to more than one (it worked, and now none of them work). We were only able to get it to work by making the traefik labels unique among the instances.
Try that and let us know how it goes. Also, it might be helpful if you put your entire docker-compose file in here for reference.
Thanks I was able to host multiple instances with SSL but there is a problem that there is only one database which can be accessed from any user. so for example I have created a credential from user1, then it is user2 can also see those in his credentials.
Hi @Asit_Joshi, while I haven’t tested it, I think having separate data folders would be the solution if the instances cannot share the database. I know that if n8n cannot find a database, it will create one upon startup.
Yes, you would need a different DATA_FOLDER for each. As that is where the database and encryption-key get stored.
Additionally also different N8N_BASIC_AUTH_USER and N8N_BASIC_AUTH_PASSWORD to make sure that you can define different user and password for basic-auth authentication.
Yes, tried with different DATA_FOLDERS and was able to see different databases.sqlite & config files but LetsEncrypt seems to only work for the first one. Which Labels should be commented or set to false to make the instances work and disable the SSL as it gives Bad Gateway error on visiting.