简体   繁体   English

apache和nodejs代理

[英]apache and nodejs proxy

I want nodejs to work together with apache. 我希望nodejs与apache一起工作。

I try to edit the httpd of apache, like so 我尝试编辑apache的httpd,就像这样

 <VirtualHost *:80>
   ServerAdmin info@admin.bb
    ServerName www.myserver.net

    ProxyRequests off

   <Proxy *>
        Order deny,allow
        Allow from all
  </Proxy>

  <Location />
        ProxyPass http://localhost:8000/
        ProxyPassReverse http://localhost:8000/
   </Location>
</VirtualHost>

I see the above method in many blogs and also here in SO. 我在很多博客中都看到了上述方法,而且在SO中也是如此。 I saved, I restarted apache and I get 我救了,我重新启动了apache而且我得到了

502 Proxy Error
Proxy Error

The proxy server received an invalid response from an upstream server.
 The proxy server could not handle the request GET /mysite/index.php.

Reason: Error reading from remote server

What is wrong with this method? 这种方法有什么问题?

Excuse my ignorance, I dont know how to solve this. 请原谅我的无知,我不知道如何解决这个问题。

Here is the part of node server, where I set a server... 这是节点服务器的一部分,我设置了一个服务器......

"use strict";
var WebSocketServer = require('websocket').server;
var http = require('http');
var pg = require('pg');


var server = http.createServer(function(request, response) {
    console.log((new Date()) + ' Received request for ' + request.url);
    response.writeHead(200, {'Content-Type': 'text/html'});
    response.end(clientHtml);
});
server.listen(8000, function() {
    console.log((new Date()) + ' Server is listening on port 8000');
});

var wsServer = new WebSocketServer({
    httpServer: server,
    autoAcceptConnections: false
});

function originIsAllowed(origin) {
  return true;
}
//FALLBACKING FOR WEBSOCKETS
var pf = require('policyfile').createServer();
pf.listen( server, function(){
  console.log(':3 yay')
});
//STOPS HERE

wsServer.on('request', function(request) {
    if (!originIsAllowed(request.origin)) {
      request.reject(); 
      console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
      return;
    }

//////////////


//prepare things to distinguish connections
var connections = {};
var connectionIDCounter = 0;
var connection = request.accept(null, request.origin);

// Store a reference to the connection using an incrementing ID
connection.id = connectionIDCounter ++;
connections[connection.id] = connection;

console.log((new Date()) + ' Connection accepted.');

/mysite/index.php /mysite/index.php

You're asking NodeJS to serve PHP pages. 您要求NodeJS提供PHP页面。 It doesn't do that. 它没有这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM