Problem with Oauth2 on Truenas

Hi there,

I installed n8n on my NAS with TrueNas Core OS and it works.
My problem: I can’t access OAuth2 which is mandatory for some Google services because I still have the localhost link.
I have an SSL domain name that points to the page of my internet box or to n8n using the dedicated port.
The console specific to the n8n plugin on my NAS is, it seems to me, in SSH, but they offer other services to activate (see photo1)
I did all the configuration steps: Node, npm, n8n, pm2, etc. and set up environment variables with “vi”, because “export” doesn’t work.
I couldn’t do the Nginx and SSL steps because with or without sudo it doesn’t work.
I have a post-installation note (photo2).
It says the config file is somewhere, but I never managed to find it.

Could you please help me ?

Uploading: Note post-installation.png…
Uploading: Services Truenas.png…

It sounds like you did not set the environment variable WEBHOOK_URL.

If you set it to for example:

WEBHOOK_URL=https://n8n.example.com/

then the OAuth URL will also change accordingly.

Generally is a good idea to check out the Server Setup Guide and see what variables are set there.

Hope that helps!

Hello Jan,

Thank you very much for taking the time to help me solve my problem.

I started by making a “simple pm2 init”, a “vi ecosystem.config.js”, then I added the code “Module.export” using the “i” key to insert and ":wq + enter to save (photo3).

Then, I made the command “pm2 start ecosystem.config.js” (photo4).

I am still in localhost on the software and the export module login credentials do not work.

Then, I did a “pm2 stop n8n”, it is stopped and yet I can still launch and use the software.

Finally, I did a “pm2 restart n8n”; the oauth credentials and link are still not working.

Module-export
Start-ecosystem

Hey @Corentin21,

I find this line interesting…

If PM2 is showing it as stopped it shouldn’t be running, Is there any chance that you have another instance running? Would you be able to try pm2 restart ecosystem.config.js --update-env as well?

There are some other possible issues in your config file but it all depends on what else you have set up.

I would probably use something like the below and see how it goes.

module.exports = {
  apps: [{
    name: "n8n",
    env: {
      N8N_BASEIC_AUTH_ACTIVE: true,
      N8N_BASIC_AUTH_USER: "your_user",
      N8N_BASIC_AUTH_PASSWORD: "CorrectHorseBatteryStaple",
      N8N_PROTOCOL: "http",
      N8N_HOST: "subdomain.mydomain.tld",
      WEBHOOK_URL: "https://subdomain.mydomain.tld",
      VUE_APP_URL_BASE_API: "https://subdomain.mydomain.tld"
    }
  }]
}

Thank you very much for your reply.

I ran the command, but nothing happened. pm2’s n8n was turned off, while the software continues to run. It would indeed seem that the n8n application of Truenas is independent of pm2.

I finally managed to open the configuration file with the command “vi /home/n8n/config/n8n-config.json”. (Photo4)

However, I don’t know how to configure this sqlite type file.

Could you let me know how I can go about it please?

config-file

Hey @Corentin21,

That looks like a json file which isn’t so bad but it is a bit more involved, Under endpoints you will need to add "webhook": "https://your-url.tld" so you would end up with something like…

"endpoints": {
  "metrics": {
    "enable": false
  },
  "webhook": "https://your-domain.tld"
}

Thanks Jon for your response.

Instead of running ‘pm2 restart ecosystem.config.js’ I ran ‘pm2_n8n restart ecosystem.config.js’ as written on the post install note.
And my domain name finally appears in the OAuth2 link.

I have reported this link in the URL field of the Google OAuth2 client ID and correctly entered the client id and the client secret on n8n, and yet, I read in the window that opens that the site is inaccessible .

N8n is accessible from “www.mydomain.fr:5678”; without the port, it redirects to the page of my box.
My subdomain being “www”, maybe “n8n” for example would be more suitable.

I tried adding “:5678” after all the “fr”, it didn’t work.
I tried to add the environment variable “N8N_PORT:5678”, without success either.

I just configured the DNS zone of “n8n.mydomain.fr” to direct it to the desired IP and port. I’m waiting for the 24 hour delay hoping that’s the problem.

1 Like