Nginx problems
-
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()
-
@Aureney You don't have any proxy commands to handle traffic between your https (port 443) traffic and the NodeBB forum running internally on port 4567 (the default unless you changed it in your config.json)
You may need a block similar to this:
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"; }
-
@tqwhite said in How to replace localhost:4567 with domain name:
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.
Slighty OT but theres no equivalent you just use curl like on any other platform..
-
@rod I copied that entire thing word for word and got the same error on and on.
listen 80; 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_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"; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:80; # 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; #} }
Error I get:
nginx: [emerg] bind() to 0.0.0.0:80 failed (48: Address already in use)
I think I didn't install nginx the right way. How do I do it?
-
We need the following things answered in order to debug your problem.
-
You appear to be running this forum on an OS X computer. I asked about this before but you didn't answer. Are you using OS X?
-
The fact that you are getting a 404 page says that you have a web server of some sort already listening on port 80. Execute the following command (assuming you are on OS X) and paste the result into a reply.
sudo lsof -i tcp:80 | grep LISTEN
-
Please report what happens when you enter
-
When you are trying to access this forum, are you using a web browser that is on the same computer as nodebb and NGINX?
It is very unlikely that your installation of NGINX is the problem.
-
-
@tqwhite said in How to replace localhost:4567 with domain name:
We need the following things answered in order to debug your problem.
-
You appear to be running this forum on an OS X computer. I asked about this before but you didn't answer. Are you using OS X?
-
The fact that you are getting a 404 page says that you have a web server of some sort already listening on port 80. Execute the following command (assuming you are on OS X) and paste the result into a reply.
sudo lsof -i tcp:80 | grep LISTEN
-
Please report what happens when you enter
-
When you are trying to access this forum, are you using a web browser that is on the same computer as nodebb and NGINX?
It is very unlikely that your installation of NGINX is the problem.
The problem is pretty clear to me: He/She refuses to adjust the nginx config to a reverse proxy according to the NodeBB docs. He/She is insisting his "word by word copied" config from another source, not related to NodeBB is correct. Which it is not. So I'm out of this debate.
-
-
@tqwhite I reinstalled Homebrew, Nginx, and NodeBB. I removed all my ports. Here is my understanding:
I set
proxy_pass
to 0.0.0.0:4567, which is the server NodeBB is using. Myserver_name
is my domain andlisten
is set to 80. Except, rather then 0.0.0.0:4567, nginx ignores the port number 4567 and uses what I setlisten
to, which was 80. Since I opened port 80, I received no errors. When I went to port 80, all I saw was the welcome to nginx page, not the actual forum. So I think nginx is not redirecting to NodeBB, but using it's own server. I know this because, after I saved the file and ransudo nginx
again, I get the error that the address 0.0.0.0:80 is already in use.@frissdiegurke I copied word for word the NodeBB docs, which is what I have meant. The problem is , the nginx.conf file I installed with home-brew is not similar to the one in the NodeBB docs, so I am not sure.
Here is it
server { listen 80; server_name eucountries.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; #}
-
@Aureney I don't know how to tell you to change your nginx configuration file but you MUST change it if you want NodeBB to work. Since you aren't clearly giving us information we can only piece this together.
REPLACE your nginx configuration file with this:
server { listen 80; server_name eucountries.com; root /var/www/html; index index.php index.html index.htm; access_log /var/log/nginx/access.log main; error_log /var/log/nginx/error.log; 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 may have to use a different path for the
root
,access_log
orerror_log
. Those may be dependent upon the operating system you are running.Then after you have replaced or changed your nginx configuration file to be what I provided RESTART Nginx. If you do not know how to do that then REBOOT the entire server/computer.
Report back after you have done that what happens then when you visit
http://eucountries.com
-