gpt4 book ai didi

ruby-on-rails - Nginx/ unicorn : Upstream timed out (110: Connection timed out) while reading response header from upstream

转载 作者:可可西里 更新时间:2023-11-01 16:47:10 26 4
gpt4 key购买 nike

我的 rails nginx/unicorn 服务器出现上游超时错误。我已尝试解决此问题,但没有找到适合我的解决方案。

我正在粘贴我在 nginx error.log 文件中得到的确切错误:

 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: default_server, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.todo.socket/", host: "xxx.xxx.xxx.xxx"

我正在关注以下 2 篇关于在我的 ubuntu EC2 机器上使用 Ruby on Rails 应用程序设置 nginx 和 unicorn 的博客:

  1. https://gist.github.com/billie66/3696537
  2. https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-unicorn-and-nginx-on-ubuntu-14-04

我能够在端口 3000 上的生产环境中运行服务器,但现在,我需要在端口 80 上运行服务器,以便我可以将 DNS 指向我的服务器 IP。我使用了以下方法来运行它:

  • unicorn.todo.socket is there which was being created after running application on unicorn using this command - unicorn -c config/unicorn.rb -E production

  • In sites-available/default, all the configurations are right including upstream.

  • In sites-enabled/default, configuration is same as sites-available/default as these both are linked. This file is included in nginx.conf file inside the /etc/nginx/ directory.

  • In log, I am getting error of upstream timeout. This was also showing that nginx taking time to connect to unicorn.todo.socket but could not debug this part as all configuration were right and running the same thing on some other server properly.

  • I have checked using 'sudo nginx -t' command for nginx configuration and this was also showing everything is OK.

  • After timeout, I am getting error of ruby 500 page in public folder, it means path and other configuration are also right.

  • I have completely removed the nginx and related component and re-installed those to server again, but no success again.

  • When I run sudo service nginx restart, it restarts the nginx and I can see the nginx server running with some pid.

  • I have changed the path for unicorn.rb listen path and this also not working.

  • The unicorn version I am using for this server, is working on another server so I did not change this.

  • Added proxy_read_timeout 150 but this is also not working.

请检查我已经尝试过的所有上述内容,如果我缺少任何在端口 80 上使用 nginx/unicorn 运行服务器的内容,请告诉我。


/etc/nginx/sites-enabled/default

upstream app {
server unix:/tmp/unicorn.todo.socket fail_timeout=0;
}

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name default_server;
root /home/ubuntu/<project_folder>/public;

try_files $uri/index.html $uri @app;

location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app;
proxy_read_timeout 150;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}

最佳答案

我遇到了同样的问题。为了修复它,我检查了/var/log/unicorn/unicorn.log 文件,发现 imagemagick 丢失了。

在 Ubuntu 上修复它:

sudo apt-get install imagemagick

关于ruby-on-rails - Nginx/ unicorn : Upstream timed out (110: Connection timed out) while reading response header from upstream,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31277652/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com