我通过Nginx代理服务器运行多个ExpressJS Node应用程序,并且每当我的用户尝试下载文件时,都会收到EPIPE错误。这不会发生在我的本地设置上(除了代理服务器之外与服务器相同),所以我认为它与我的Nginx配置有关。
以下是我的Nginx配置:
user www www;
worker_processes 1;
error_log /home/alex/logs/error.log;
pid /var/run/nginx.pid;
worker_rlimit_nofile 8192;
events {
worker_connections 4096; ## Default: 1024
}
http {
include mime.types;
index index.html index.htm index.php;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /home/alex/logs/access.log main;
sendfile on;
tcp_nopush on;
gzip on;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
include /etc/nginx/conf.d/*.conf;
}
server {
listen 80;
server_name example.com;
# log access and stuff
access_log /home/alex/logs/example-site.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# Proxy to the NodeJS server
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8999;
}
# redirect server error pages to their HTML
include /etc/nginx/errpages.conf;
}
ExpressJS服务器使用以下代码发送下载:
app.get('/citrite/p/:patch', function(req, res)
{
if(set.citFiles.indexOf(req.params.patch) == -1)
{
res.send(mbuild.get404());
}
else
{
track.incrViewcount(req.params.patch, 'citrite');
res.download(set.citDir + '/' + req.params.patch, files.doneSaving);
}
});
该代码和其他所有内容在我的本地git仓库中工作正常,但是当我从那里推出并拉动服务器端时,该站点会发出尖叫声 - 它会在用户结束时超时并给我控制台中出现EPIPE错误。我正在运行Node.js版本4.2.1和ExpressJS版本4.13.3。
答案 0 :(得分:0)
我弄清楚问题是什么:显然,将 private void Page_Loaded(object sender, RoutedEventArgs e)
{
myModelView = new MyModelView();
this.DataContext = myModelView;
}
设置为sendfile
是导致下载停顿的原因,并将其关闭(具体来说,删除配置中的指令)已修复问题。不完全确定为什么会干扰,但摆脱设置可以解决问题。