Can't get Nginx to work
-
Hello,
I'm in the process of setting up a nodebb forum on a virtual machine. The goal is to make the forum accessible from the local network via the local machine's ip, since I don't own a domain yet. I don't want to have to specify the port when entering the ip address into a browser
Current issues:
-
If I enter the ip address of the VM into the browser of a computer on the same local network, I don't get forwarded to the forum if the port isn't specified. I just see the Nginx default page.
-
If I enter the ip address of the VM with the nodebbb port 4567, I can access the forum, but unfortunately, I experience regular connection issues.
I read that both issues can be connected, so hopefully it's an easy fix.
Nginx Status
Nginx NodeBB Config
NodeBB Config
Nginx Config
What am I doing wrong?
Thanks!
-
-
server_name
should be set to127.0.0.1
-
Thank you! This fixed the issue that I couldn't access the forum by entering the local ip address of the virtual machine into the browser (http://192.168.178.54) of a computer in the same network.
Unfortunately, the connection issues still persists, whether or not I connect from the VM itself or from a different computer.
Adding the port to the url or leaving it out didn't make a difference. I also tried the local ip as URL with and without specified port.
-
The URL in your browser bar and the
url
value in config.json must match exactly to fix that issue.So it should work if you leave out the port and use
https://your.lan.ip
in config.jsonSee the following topic for more info:
[FAQ] Websockets not working due to misconfigured origins
This FAQ is applicable for the following situations: You're receiving the following error in the Javascript console: WebSocket connection to 'wss:///socket...
NodeBB Community (community.nodebb.org)
-
@PitaJ said in Can't get Nginx to work:
The URL in your browser bar and the
url
value in config.json must match exactly to fix that issue.So it should work if you leave out the port and use
https://your.lan.ip
in config.jsonSee the following topic for more info:
[FAQ] Websockets not working due to misconfigured origins
This FAQ is applicable for the following situations: You're receiving the following error in the Javascript console: WebSocket connection to 'wss:///socket...
NodeBB Community (community.nodebb.org)
I just tried that without success (yes, I made sure to restart NodeBB). Also, the developer mode doesn't fix the problem (contrary to what's stated in the linked thread).
I'm not sure if this has anything to do with the issue, but I had a few errors while setting up NodeBB initially, which I had to address.
npm ERR! path /home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall open npm ERR! Error: EACCES: permission denied, open '/home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e' npm ERR! { [Error: EACCES: permission denied, open '/home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e'] npm ERR! cause: npm ERR! { Error: EACCES: permission denied, open '/home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e' npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: npm ERR! '/home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e' }, npm ERR! isOperational: true, npm ERR! stack: npm ERR! 'Error: EACCES: permission denied, open \'/home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: npm ERR! '/home/benedikt/.npm/index-v5/2b/b7/5605911c6e8a323c274c5905a25a7425d38df8289efa2b50cc0e37b1dd4e' } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator (though this is not recommended). npm ERR! A complete log of this run can be found in: npm ERR! /home/benedikt/.npm/_logs/2019-03-26T11_23_28_953Z-debug.log
This fixed the error:
benedikt@ubuntu:/var/www/nodebb/NodeBB$ sudo npm install -g --unsafe-perm=true --allow-root + [email protected] added 1 package in 3.912s benedikt@ubuntu:/var/www/nodebb/NodeBB$ ./nodebb setup 2019-03-26T11:25:02.767Z [19309] - info: NodeBB Setup Triggered via Command Line Welcome to NodeBB v1.11.2!
Another issue that came up a few times during the installation was that benchpress was missing.
benedikt@ubuntu:/var/www/nodebb/NodeBB$ ./nodebb setup 2019-03-26T11:16:57.048Z [undefined/19138] - error: uncaughtException: Cannot find module 'benchpressjs' Error: Cannot find module 'benchpressjs' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (/var/www/nodebb/NodeBB/install/web.js:13:18) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) {"error":{"code":"MODULE_NOT_FOUND"},"stack":"Error: Cannot find module 'benchpressjs'\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)\n at Function.Module._load (internal/modules/cjs/loader.js:508:25)\n at Module.require (internal/modules/cjs/loader.js:637:17)\n at require (internal/modules/cjs/helpers.js:22:18)\n at Object.<anonymous> (/var/www/nodebb/NodeBB/install/web.js:13:18)\n at Module._compile (internal/modules/cjs/loader.js:701:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)\n at Module.load (internal/modules/cjs/loader.js:600:32)\n at tryModuleLoad (internal/modules/cjs/loader.js:539:12)\n at Function.Module._load (internal/modules/cjs/loader.js:531:3)","exception":true,"date":"Tue Mar 26 2019 12:16:57 GMT+0100 (Central European Standard Time)","process":{"pid":19138,"uid":1000,"gid":1000,"cwd":"/var/www/nodebb/NodeBB","execPath":"/usr/bin/node","version":"v10.15.3","argv":["/usr/bin/node","/var/www/nodebb/NodeBB/nodebb","setup"],"memoryUsage":{"rss":57671680,"heapTotal":37748736,"heapUsed":21650432,"external":887293}},"os":{"loadavg":[0.33642578125,0.35888671875,0.2109375],"uptime":6022},"trace":[{"column":15,"file":"internal/modules/cjs/loader.js","function":"Module._resolveFilename","line":582,"method":"_resolveFilename","native":false},{"column":25,"file":"internal/modules/cjs/loader.js","function":"Module._load","line":508,"method":"_load","native":false},{"column":17,"file":"internal/modules/cjs/loader.js","function":"Module.require","line":637,"method":"require","native":false},{"column":18,"file":"internal/modules/cjs/helpers.js","function":"require","line":22,"method":null,"native":false},{"column":18,"file":"/var/www/nodebb/NodeBB/install/web.js","function":null,"line":13,"method":null,"native":false},{"column":30,"file":"internal/modules/cjs/loader.js","function":"Module._compile","line":701,"method":"_compile","native":false},{"column":10,"file":"internal/modules/cjs/loader.js","function":"Module._extensions..js","line":712,"method":".js","native":false},{"column":32,"file":"internal/modules/cjs/loader.js","function":"Module.load","line":600,"method":"load","native":false},{"column":12,"file":"internal/modules/cjs/loader.js","function":"tryModuleLoad","line":539,"method":null,"native":false},{"column":3,"file":"internal/modules/cjs/loader.js","function":"Module._load","line":531,"method":"_load","native":false}]} benedikt@ubuntu:/var/www/nodebb/NodeBB$ sudo npm install > [email protected] install /var/www/nodebb/NodeBB/node_modules/benchpressjs > cd rust/benchpress-rs && npm install > [email protected] install /var/www/nodebb/NodeBB/node_modules/benchpressjs/rust/benchpress-rs > neon build >> build.log 2>&1 || exit 0 npm notice created a lockfile as package-lock.json. You should commit this file. added 87 packages from 83 contributors in 4.292s āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā npm update check failed ā ā Try running with sudo or get access ā ā to the local update config store via ā ā sudo chown -R $USER:$(id -gn $USER) /home/benedikt/.config ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā npm notice created a lockfile as package-lock.json. You should commit this file. added 14 packages from 66 contributors and audited 4333 packages in 15.373s found 7 vulnerabilities (1 low, 5 moderate, 1 high) run `npm audit fix` to fix them, or `npm audit` for details
Fix:
benedikt@ubuntu:/var/www/nodebb/NodeBB$ sudo chown -R $USER:$(id -gn $USER) /home/benedikt/.config
Last but not least:
Mar 26 15:36:14 ubuntu system[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Fix:
mkdir /etc/systemd/system/nginx.service.d printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf systemctl daemon-reload systemctl restart nginx
I really appreciate your help.
-
@Goldrush12 said in Can't get Nginx to work:
I just tried that without success (yes, I made sure to restart NodeBB). Also, the developer mode doesn't fix the problem (contrary to what's stated in the linked thread).
Okay, so it must be something else.
I'm not sure if this has anything to do with the issue, but I had a few errors while setting up NodeBB initially, which I had to address.
Wow, um, big red flag there. How did you install NodeBB in the first place? It may be wise to start from scratch and reinstall with correct permissions from the get-go. You absolutely should not use
sudo
to install or run NodeBB. The only installation-related things you need root access for are nginx configuration and maybe changing directory privileges before installing NodeBB.What OS are you installing NodeBB on? Are you following any tutorials or instructions?
-
@PitaJ said in Can't get Nginx to work:
@Goldrush12 said in Can't get Nginx to work:
I just tried that without success (yes, I made sure to restart NodeBB). Also, the developer mode doesn't fix the problem (contrary to what's stated in the linked thread).
Okay, so it must be something else.
I'm not sure if this has anything to do with the issue, but I had a few errors while setting up NodeBB initially, which I had to address.
Wow, um, big red flag there. How did you install NodeBB in the first place? It may be wise to start from scratch and reinstall with correct permissions from the get-go. You absolutely should not use
sudo
to install or run NodeBB. The only installation-related things you need root access for are nginx configuration and maybe changing directory privileges before installing NodeBB.What OS are you installing NodeBB on? Are you following any tutorials or instructions?
My OS is Ubuntu 18.04 and I followed a documentation from your website. I started from scratch and it's running fine now! I assume the guide I used must have been outdated, which led to some errors. I must say that it might make sense to clean up the documentary and make sure that only one version of the installation guide for every OS exists to avoid confusion.
Thank you for your help!