nginx与节点js和CodeIgniter

时间:2013-10-23 20:01:47

标签: node.js codeigniter nginx

我一直在试图让我的整个上午工作。 我在Linode托管的CentOS上全新安装了Nginx和Nodejs ....

我有一个从root或public_html运行的CodeIgniter的工作安装。 在public_html中,我有一个名为/ nodejs的目录,我正在尝试从中运行节点服务器。

我收到了502 Bad Gateway错误...

这是我的error.log文件。

2013/10/23 19:21:07 [error] 2614#0: *1 connect() failed (111: Connection refused) while     connecting to upstream, client: xx.x.xx.xxx, server: mydomain.com, request: "GET /nodejs/index.html HTTP/1.1", upstream: "http://127.0.0.1:3031/nodejs/index.html", host: "mydomain.com"

这是我的/opt/nginx/conf/nginx.conf

worker_processes 1;

events {
    worker_connections  1024;
}

http {
    upstream app_nodejs {
        server 127.0.0.1:3031;
    }

include mime.types;
default_type  application/octet-stream;
sendfile on;

server {
    server_name mydomain.com;
    large_client_header_buffers 4 16k;
    access_log /srv/www/mydomain.com/logs/access.log;
    error_log /srv/www/mydomain.com/logs/error.log;
    root /srv/www/mydomain.com/public_html;
    index index.php index.html;

    location ~* ^/(css|fonts)/(.+)$ {
        root /srv/www/mydomain.com/public_html/assets;
    }

    location / {
        try_files $uri $uri/ @ci;
    }

    location ~* /nodejs {
        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://app_nodejs;
        proxy_redirect off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location @ci {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }
    }

    location ~ \.php {
        include fastcgi_params;
        set $php_root /srv/www/mydomain.com/public_html;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_param REQUEST_URI $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME /srv/www/mydomain.com/public_html$fastcgi_script_name;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_index index.php;
    }
}
}

任何帮助将不胜感激。感谢

1 个答案:

答案 0 :(得分:1)

我不是nginx专家,但看起来你错过了一个关闭'}'的地方。 http部分永远不会关闭。