nodebb正确安装然后502 Bad Gateway

时间:2016-01-08 23:21:55

标签: node.js nginx nodebb

我尝试在我的服务器上为域le.club.systemes.sonores.rocks安装nodebb。 我希望它的工作原理如下: nginx>的node.js

有关信息:

nginx配置为使用FPM。

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

我做了什么

我用这些页面安装nodebb: https://docs.nodebb.org/en/latest/installing/os/ubuntu.html https://docs.nodebb.org/en/latest/configuring/proxies/nginx.html

我用这个页面更新node.js: https://davidwalsh.name/upgrade-nodejs

一开始,我得到502 Bad Gateway error

我尝试在这些页面的帮助下解决它: nginx: connect() failed (111: Connection refused) while connecting to upstream http://jvdc.me/fix-502-bad-gateway-error-on-nginx-server-after-upgrading-php/

最后我得到了配置页面。最后,我得到一个成功的消息和按钮来启动论坛。

论坛从未运行,在重新加载时我收到502 Bad Gateway错误。

我尝试在文件夹nodebb中启动,但它并没有明显改变任何内容。

我尝试重新启动FPM和nginx而没有成功。

service php5-fpm restart
service nginx restart

我的配置:

我的nginx主机

#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

错误日志

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"

用于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)

我必须配置为在nginx启动时启动node.js吗?

服务器配置有问题吗?

代理配置?

提前感谢您的帮助。 JB

0 个答案:

没有答案