我正在托管apache和node.js服务器以及代理到节点服务器的apache服务器.我的框架是express.js,我正在使用amCharts.I有超时代理设置为600.当我打开我的网站时,我只得到静态内容而不是amCharts的动态内容.
这是我的服务器端代码:
var express = require('express'); var routes = require('./routes'); var user = require('./routes/user'); var http = require('http'); var path = require('path'); var fs = require('fs'); var data = ''; var app = express(); var server = app.listen(3000); var io = require('socket.io').listen(server); // all environments //app.set('port', process.env.PORT || 3000); //app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.json()); app.use(express.urlencoded()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); io.sockets.on('connection', function (socket) { setInterval(function(){ var file = __dirname + '/config.json'; fs.readFile(file, 'utf8', function (err, data) { if (err) { console.log('Error: ' + err); return; } data = JSON.parse(data); // You can save those values somewhere or just log them to the console console.dir(data); socket.emit('news', { hello: data}); }); }, 5000); }); app.get('/', function (req, res){ res.render('map1.html'); }); app.set('views', __dirname + '/views'); app.engine('html', require('ejs').renderFile); // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } console.log("Express server listening on port 3000");
控制台出错是:
GET http://localhost/ammap.css 502 (Proxy Error) localhost/:7 GET http://localhost/ammap.js 502 (Proxy Error) localhost/:8 GET http://localhost/worldLow.js 502 (Proxy Error) localhost/:10 GET http://localhost/jquery.min.js 502 (Proxy Error) localhost/:11 Uncaught ReferenceError: $ is not defined localhost/:85 extension connect DragAndDropController.js:83 GET http://localhost/socket.io/1/?t=1394706750306 502 (Proxy Error)
我的apache conf文件配置是
ProxyRequests offOrder deny,allow Allow from all ProxyTimeout 600ProxyPass http://localhost:3000 ProxyPassReverse http://localhost:3000
我的客户端代码map1.html
amMap examples HighMedLowMaintenanceOn MoveOthers
Gyanesh Gour.. 24
解决了这个问题.在虚拟主机配置文件中我刚添加:
ProxyPass http://localhost:3000/ ProxyPassReverse http://localhost:3000/
/在代理传递结束时它工作.
解决了这个问题.在虚拟主机配置文件中我刚添加:
ProxyPass http://localhost:3000/ ProxyPassReverse http://localhost:3000/
/在代理传递结束时它工作.