【发布时间】:2014-05-11 23:17:08
【问题描述】:
我已经通过代理、proxy_http 模式为 Apache 服务器配置了 Node.js 服务器,并且运行良好。但是现在当我启动我的 Node.js 服务器时,我在 ssh 控制台上收到了正在运行的通知消息:“好的,服务器正在运行”,但是当我通过浏览器访问 Node.js 服务器时 @ 987654321@,我收到 502 错误(代理错误) - 在我获得 200 状态之前!
我不知道为什么我现在无法获得 200 状态!我没有更改 Node.js 服务器文件的任何内容。所有者是 root:root。我重新启动了 Ubuntu 12.04 服务器,它在重新启动后工作。
proxy 和 proxy_http 模块已启用。
我从 Apache 日志中得到以下错误:
(20014)Internal error: proxy: error reading status line from remote server localhost:9000
proxy: Error reading from remote server returned by /node
以下是站点可用的/etc/apache2/sites-available/example.com 配置以启用代理
<VirtualHost *:80>
.
.
ProxyPass /n http://localhost:9000/
ProxyPassReverse /n http://localhost:9000/
.
.
</VirtualHost>
Node.js 服务器代码:
var http=require('http');
var mysql = require('mysql');
var util = require('util');
var url = require('url');
var server=http.createServer(function(req,res){
//res.end('Connected');
});
server.on('listening',function(){
console.log('ok, server is running');
});
server.listen(9000);
非常感谢您的意见,因为我已经尝试了很多但没有运气:(
谢谢。
【问题讨论】:
标签: javascript node.js apache proxy