我希望有人能够对此有所了解。我们有一个使用 wicked_pdf 库生成 PDF 的 Rails 2 应用程序。我们正在由 nginx 代理的 unicorn 下运行该应用程序。
问题是,每当应用程序尝试提供 PDF 时,它就会超时,而 nginx 会报告 404。我已经通过 unicorn 端口检查了应用程序,它工作正常,所以是 unicorn 和 nginx 之间发生了一些事情导致失败。
日志文件没有报告任何有用的信息。应用程序日志只是正常报告所有内容,但不输出该Sending data
行。nginx 日志报告*443 upstream prematurely closed connection while reading response header from upstream, client
.
unicorn错误日志报告连接超时,worker正在被杀死,但是PDF生成不需要30秒:
worker=2 PID:14099 timeout (31s > 30s), killing
reaped #<Process::Status: pid=14099,signaled(SIGKILL=9)> worker=2
worker=2 ready
我觉得我们在网站的 nginx 配置中遗漏了一些东西,但我不确定从哪里开始寻找。
我在下面包含了 nginx 配置:
server {
listen *:80;
server_name server_name.example.com;
root /var/apps/application/current/public;
try_files /system/maintenance.html $uri $uri/index.html @app;
location @app {
proxy_pass http://unix:/tmp/application.sock;
proxy_set_header Host $http_host;
}
error_page 404 400 500 502 /error.html;
location = /error.html {
root /var/www;
}
}