If I comment the response at server, then it will not work and will get Error 502. It should be:
var server=http.createServer(function(req,res){
res.end('Connected');
});
Frage
I have configured Node.js server with the Apache server via proxy, proxy_http modes and it was working fine. But now when I start my Node.js server, I get the running notification message on ssh console which is: "ok, server is running", but when I access the Node.js server via browser http://example.com/node/
, I get 502 Error (Proxy Error) - Before I was getting 200 status!
I don't know why now I am unable to get 200 status! I haven't changed anything for the Node.js server file. The owner is root:root. I rebooted the Ubuntu 12.04 server and it was working after the reboot.
The modules proxy and proxy_http are enabled.
I got the below errors from Apache log:
(20014)Internal error: proxy: error reading status line from remote server localhost:9000
proxy: Error reading from remote server returned by /node
Below is the sites-available /etc/apache2/sites-available/example.com
configuration to enable proxy
<VirtualHost *:80>
.
.
ProxyPass /n http://localhost:9000/
ProxyPassReverse /n http://localhost:9000/
.
.
</VirtualHost>
The Node.js server code:
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);
I would greatly appreciate your inputs as I have tried a lot with no luck :(
Thanks.
Lösung
If I comment the response at server, then it will not work and will get Error 502. It should be:
var server=http.createServer(function(req,res){
res.end('Connected');
});