0

我尝试在我的服务器上为域安装 nodebb le.club.systemes.sonores.rocks。我希望它像这样工作: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 denied) while connection to upstream http://jvdc.me/fix-502-bad-gateway-error-on-nginx-服务器-升级后-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 配置

/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

错误日志

对于 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 [编辑]

/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

4

0 回答 0