Hey guys, I deployed n8n within portainer, I need to do some verification with a static file must be placed at the root of the n8n instance.
I tried to set N8N_ADDITIONAL_NON_UI_ROUTES to xxxx_verify.txt and xxxx_verify.txt:xxxx_verify as the environment on portainer, and mounted the txt file to /usr/local/lib/node_modules/n8n/dist/, but still got 404 error on https://test.test.com/xxxx_verify.txt.
What is the error message (if any)?
Cannot GET /xxxx_verify.txt
Please share your workflow
touch verification file and write content to it.
mount host path to container
add environment to the container
visit url
Share the output returned by the last node
Information on your n8n setup
n8n version: docker latest
Database (default: SQLite): postgresql
n8n EXECUTIONS_PROCESS setting (default: own, main): own
Running n8n via (Docker, npm, n8n cloud, desktop app): docker on portainer
Are you able to use something like an nginx reverse proxy? You can route to any URL/file that way. We have one client on n8n.domain.net and all reports are hosted at n8n.domain.net/reports. We just routed /reports to a directory on the host via nginx config.
Where did you find the N8N_ADDITIONAL_NON_UI_ROUTES env var? I have not seen it before and its not in the documentation.
*I was in fact able to find it via github, where it was added in 2022 and doesn’t seem to referenced anywhere else. I do believe it works sort of how you think, where it prevents certain routes to not proc the UI.
But:
I (think) it seems to only be valid for routes, not files.
I (think) this is potentially used only internally, as some env vars are not adjustable.
I would advise trying to use some kind of reverse proxy webserver like nginx to force sub routes.
Like I said, that is an undocumented feature and I am unsure if its intended to be used how you tried to use it.
Could you provide your setup for when others try use this to provide more context in how you solved? As there is no other details online about it I was able to easily find.
WEBHOOK_URL
to be the desired subdomain name, eg. n8n.abc.com
Next, map a locally modified server.js to the container path: /usr/local/lib/node_modules/n8n/dist/server.js
And here’s the modified server.js, only line #311 is added, no more other changes, you can use docker cp to copy the original file out, then modify it:
If you are running n8n in production, I’d recommend using a reverse proxy (if you aren’t using one already), and then routing the urls in the reverse-proxy to another static file server.
The additional routes option is neither well documented, nor commonly used, and might disappear in a future version of n8n.
Routing these on a reverse proxy would be a much safer option in the long term.