2013-10-23 35 views
0

我一直在敲我的頭試圖讓這個工作整個上午。 我在Linode上託管的CentOS上安裝了Nginx和Nodejs。ngnix與nodejs和CodeIgniter

我有一個從根目錄或public_html運行的CodeIgniter的工作安裝。 在public_html中我有一個名爲/ nodejs的目錄,我嘗試從中運行節點服務器。

我得到一個502錯誤網關錯誤...

這在我的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

我不是nginx專家,但它看起來像你錯過了關閉'}'在那裏的某個地方。 http部分永遠不會關閉。

+0

是壞的複製和粘貼。 – user1840958