这些是症状:
每当我尝试将文件上传到我的节点服务器时,我收到502响应,响应在以下两者之间变化:
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /grimoireworks/admin/uploads/uploadimage.
Reason: Error reading from remote server
Apache/2.4.10 (Debian) Server at 50.116.34.26 Port 80
和
Bad Gateway
The proxy server received an invalid response from an upstream server.
Apache/2.4.10 (Debian) Server at 50.116.34.26 Port 80
编辑:现在刚拿到这个:
Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.4.10 (Debian) Server at 50.116.34.26 Port 80
当发生这种情况时,所有会话都会被删除。
这是我的nodejs代码,它使用multer来处理文件上传:
app.post('/admin/uploads/uploadimage',
ajaxAdminLoggedIn,
upload.single('image_file'),
function(req, res) {
console.log("start of upload");
req.socket.setTimeout(10000);
var supportedTypes = ['image/jpeg', 'image/png', 'image/gif'];
var type = req.file.mimetype;//mime.lookup(req.files.image_file.path);
console.log("before supportedTypes check");
if (supportedTypes.indexOf(type) == -1) {
fs.unlink(req.file.path);
return res.send(415, 'Supported image formats: jpeg, jpg, jpe, gif, png.');
}
console.log("before targetPath");
var targetPath = __dirname + '/public/images/';
if (req.body.image_type == "wizard") {
targetPath += 'classes/';
} else if (req.body.image_type == "spell") {
targetPath += 'spells/';
} else {
fs.unlink(req.file.path);
return res.send(415, 'Invalid image type.');
}
console.log("before tempPath");
var tempPath = req.file.path;
console.log("before createReadStream");
var source = fs.createReadStream(tempPath);
var dest = fs.createWriteStream(targetPath + req.file.originalname);
console.log(tempPath);
console.log(targetPath + req.file.originalname);
source.pipe(dest);
console.log("after pipe");
source.on('error', function(err) {
if (err) {
return res.send(500, 'Something went wrong');
}
});
source.on('end', function() {
//delete file from temp folder
fs.unlink(tempPath, function(err) {
if (err) {
return res.send(500, 'Something went wrong');
}
res.redirect('back');
}); //#end - unlink
}); //#end - on.end
}
);
没有任何日志显示在输出文件中。
虽然文件已正确上传到临时文件夹。
这是我目前的ProxyPass:
ProxyPass /grimoireworks http://localhost:6161 timeout=10000
我也试过这个无济于事:
ProxyPass /grimoireworks http://localhost:6161 retry=1 acquire=3000 timeout=10000 keepalive=on
这些是服务器上的日志:
[Sat Oct 15 11:45:44.242028 2016] [proxy_http:error] [pid 9163] (20014)Internal error: [client 189.35.255.189:20862] AH01102: error reading status line from remote server 127.0.0.1:6161, referer: http://50.116.34.26/grimoireworks/admin/uploads
[Sat Oct 15 11:45:44.242088 2016] [proxy:error] [pid 9163] [client 189.35.255.189:20862] AH00898: Error reading from remote server returned by /grimoireworks/admin/uploads/uploadimage, referer: http://50.116.34.26/grimoireworks/admin/uploads
有人可以帮我一把吗?这让我疯了......