1

I try to install nodebb on my server for the domain le.club.systemes.sonores.rocks. I would like it works like that: nginx > node.js

For information:

nginx is configured to use FPM.

# node -v
v5.4.0
# npm -v
3.3.12

What i did

I install nodebb with these pages: https://docs.nodebb.org/en/latest/installing/os/ubuntu.html https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html

I update node.js with this page: https://davidwalsh.name/upgrade-nodejs

At the beginning, i get a 502 Bad Gateway error.

I try to solve it with the help of these pages: nginx: connect() failed (111: Connection refused) while connecting to upstream http://jvdc.me/fix-502-bad-gateway-error-on-nginx-server-after-upgrading-php/

Finally i get the config page. At the end, i get a successful message and th button to launch the forum.

The forum never run and at reload i get a 502 Bad Gateway error.

I try start in the folder nodebb but it doesn't change anything apparently.

I try to restart FPM and nginxwithout success.

service php5-fpm restart
service nginx restart

My configuration:

my nginx host

#vi /etc/nginx/sites-available/le.club.systemes.sonores.rocks

upstream le.club.systemes.sonores.rocks {
        ip_hash;
        server localhost:4567;
        keepalive 8;
}

server {

        listen 80;
        listen [::]:80;

        #root /usr/share/nginx/html/node/le.club.systemes.sonores.rocks;
        #index index.php index.html index.htm;

        # Make site accessible from http://le.club.systemes.sonores.rocks/
        server_name le.club.systemes.sonores.rocks;

        #large_client_header_buffers 4 32k;

        # Logs
        access_log /var/log/leclubsystemessonoresrocks.access_log;
        error_log /var/log/leclubsystemessonoresrocks.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://localhost:4567/;
                proxy_pass http://le.club.systemes.sonores.rocks/;
                proxy_redirect off;

                # Socket.IO Support
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }

        # Redirect server error pages to the static page
        #error_page   403  /403.html;
        #error_page 404 /404.html;
        #error_page   500 502 503 504  /50x.html;

}

nodebb config

/usr/share/nginx/html/node/le.club.systemes.sonores.rocks/nodebb# vi config.json


{
    "url": "http://localhost:4567",
    "secret": "xxx",
    "database": "mongo",
    "port": 4567,
    "mongo": {
        "host": "localhost",
        "port": "4567",
        "username": "yyy",
        "database": "0"
    }
}

nginx.conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        ##
        # Special for 502 error
        ##

        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;

        ##
        # Access control
        ##

        include blockips.conf;

}

www.config

# vi /etc/php5/fpm/pool.d/www.conf 
listen = /var/run/php5-fpm.sock
;listen = 127.0.0.1:9000

Error log

for nginx

# vi /var/log/leclubsystemessonoresrocks.error_log

2016/01/08 23:20:28 [error] 31636#0: *29 connect() failed (111: Connection refused) while connecting to upstream, client: 2a01:e35:xxx:xxx:xxx:xxx:xxx:xxx, server: le.club.systemes.sonores.rocks, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:4567/", host: "le.club.systemes.sonores.rocks"

for nodebb [edit]

/usr/share/nginx/html/node/le.club.systemes.sonores.rocks/nodebb/l
ogs# vi output.log

8/1 22:58 [30578] - ^[[32minfo^[[39m: Time: Fri Jan 08 2016 22:58:01 GMT+0100 (CET)
8/1 22:58 [30578] - ^[[32minfo^[[39m: Initializing NodeBB v0.9.3
8/1 22:58 [30578] - ^[[31merror^[[39m: NodeBB could not connect to your Mongo database. Mongo returned the following error: connect ECONNREFUSED 127.0.0.1:4567
8/1 22:58 [30578] - ^[[31merror^[[39m: Error: connect ECONNREFUSED 127.0.0.1:4567
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1063:14)
[cluster] Child Process (30578) has exited (code: 0, signal: null)

Do i have to configure to start node.js when nginx start?

Could it be a problem with the server configuration?

Of the proxy config?

Thank you in advance for any help. jb

Community
  • 1
  • 1
jbo
  • 129
  • 3
  • 14
  • Check if your node server is running or has errors. The error log says it can't connect with your nodejs server. – hassansin Jan 08 '16 at 23:47
  • i have add the nodebb error log. i will check. – jbo Jan 09 '16 at 07:59
  • I have check for the mongodb > show dbs but my database doesn't seems to have been created: i only see local 0.078125GB... If i create it, do i have to reinstall nodebb? – jbo Jan 09 '16 at 08:56
  • I don't know about nodebb... but from error log, it seems nodebb can't connect with mongodb server. My guess is you put wrong port for mongodb as it says `4567`. It should be `27019` by default. – hassansin Jan 09 '16 at 14:28
  • Thank you @hassansin for your help. it works when i redo the configuration with the good mongodb port and after i create a new user for the database. – jbo Jan 23 '16 at 17:48

0 Answers0