Nginx problems
-
@pichalite I did some searching and managed to get my domain name into it. When I run the domain name (example.com:4567) on other devices, it refuses to connect. It only works in the computer hosting the server.
-
I followed the instructions to use nginx to forward my domain name to 0.0.0.0:4567, but I get this error when I ran
sudo nginx
nginx: [emerg] bind() to 0.0.0.0:4567 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:4567 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:4567 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:4567 failed (48: Address already in use) nginx: [emerg] bind() to 0.0.0.0:4567 failed (48: Address already in use) nginx: [emerg] still could not bind()
-
@Aureney Which instructions did you follow? What does your nginx config look like?
-
@frissdiegurke
One in the docs.listen 4567; server_name domain-name.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://0.0.0.0; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
-
@Aureney Then please read the docs again: https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html
I can't see any place where you could've gotten your bad config from.
The reason for the errors is the
listen 4567;
instead oflisten 80;
orlisten 443;
for TLS/SSL. But the rest of your config won't work either. -
@frissdiegurke One more thing. After I've done the domain and nginx, will users from other devices be able to see the forum?
-
@Aureney If you've done everything right, yes.
-
Here is my working NGINX config:
server { listen 80; server_name plansForum.cmerdc.org; client_max_body_size 5M; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:4567/; proxy_redirect off; # Socket.IO Support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
You should be able to use it as is except for the server_name which must, of course be changed to your domain.
-
If the mention of including Apache/PHP was intentional, you can use this config section as a model:
server { listen 80; server_name cmerdc.org; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } }
You will have to change the port Apache listens to to be 8080 (or whatever you choose). In my Ubuntu installation, that is done in the file
/etc/apache2/ports.conf
Don't forget to restart Apache and test it by going curl'ing http://127.0.0.1:8080.
And, of course, the server_name has to match your domain.
-
@tqwhite I think this might be the problem. I installed nginx following this guide and the NodeBB forum is already running and using 0.0.0.0:4567. I also don't have an apache2 folder. Regular "my-domain.org" links to nginx, and the "my-domain.org:4567" links to the actual forum. I can't see anything else I did wrong.
-
@Aureney You're following the wrong docs. Those docs are intended for static file delivery, not for a node.js application that is already listening to a port (like NodeBB does).
listen 4567;
within nginx says you want to listen for requests toexample.com:4567
.
If you want to listen to http requests forexample.com
you need tolisten 80;
.
You now need to internally forward (proxy) those requests to the port on which NodeBB is listening (4567
by default). Take a look at the docs I've referenced above for examples of correct configurations. -
Along the lines of @frissdiegurke, but to go one step further you can have your forum on a port other than 80/443 but it cannot be the same port that NodeBB is actually operating on.
Specifically you can't have your Nginx or Apache listening on port 4567 and then proxying to socket.io also on port 4567. Either chose a different port for the web access or in your NodeBB config.json change NodeBB to run on a different port.
-
@Aureney Here are some questions...
What operating system are you working with?
If it's a Linux (or OS X), what happens when you type
curl http://0.0.0.0:4567
and, since I guess that does nothing, what happens with
curl http://127.0.0.1:4567
If you are using Windows, well, I googled "windows curl equivalent" and was reminded that I'm really glad I don't use Windows. You might find it more useful.
After that, what do you see at
/var/log/nginx/error.log
If you need more help. I'll check here again later today.
Good luck.
-
@Aureney I take it, then, that you are running this on OS X on your Macintosh, right?
NGINX is presently at 1.11.something. I am running 1.9 on my Macbook and the snippet syntax I posted works. So, the version is not the problem.
If you run
nginx -t
nginx will evaluate your config file and tell you about errors. It will also tell you the config file path.
One error it might report is 'access denied' for the .pid file. This is a result of running nginx without 'sudo'. Unless you did something special, running NGINX requires sudo.
Also, you did report on the curl tests I asked about previously. Please do.
-
listen 443; server_name domainnamehere.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://0.0.0.0:4567/; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one #
#location ~ /\.ht { # deny all; #} }
@tqwhite Get this, even though nginx doesn't work
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
and on the curl tests, same error
2016/05/25 16:59:40 [emerg] 4670#0: bind() to 0.0.0.0:4567 failed (48: Address already in use) 2016/05/25 16:59:40 [emerg] 4670#0: bind() to 0.0.0.0:4567 failed (48: Address already in use) 2016/05/25 16:59:40 [emerg] 4670#0: bind() to 0.0.0.0:4567 failed (48: Address already in use) 2016/05/25 16:59:40 [emerg] 4670#0: bind() to 0.0.0.0:4567 failed (48: Address already in use) 2016/05/25 16:59:40 [emerg] 4670#0: bind() to 0.0.0.0:4567 failed (48: Address already in use) 2016/05/25 16:59:40 [emerg] 4670#0: still could not bind()