我正在运行Nginx / unicorn我从nginx获取错误“失败(111:连接被拒绝),同时连接到上游”。它工作了一段时间,但在数字海洋支持重新启动我的液滴(另一个问题)后,我再也无法恢复工作了。我看过记忆,旋转日志,弹回服务器,nginx和独角兽。我已经尝试过更改插座的位置,名称和权限,毕竟我甚至尝试过扔圣水并在我的终端尖叫以消除恶魔。 :-)似乎我已经尝试了所有DO支持,谷歌和stackoverflow必须提供。我不知道我是否忽略了某些东西,或者我已经尝试了很多,以至于我现在搞砸了什么。这是所有的配置,分析等等......
Nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
worker_rlimit_nofile 30000;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
proxy_connect_timeout 60;
proxy_read_timeout 60;
proxy_send_timeout 60;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/xml text/css text/comma-separated-values;
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
# FAIL upstream app_server {server unix:/home/puma/sockets/puma.sock fail_timeout=0; }
# FAIL upstream app_server {server unix:/home/rails/tmp/sockets/unicorn.flossfish.sock fail_timeout=0; }
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
===========================
nginx/sited-enabled/default
server {
listen 80;
root /home/rails/public;
#server_name _;
server_name localhost;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
try_files $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_server;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
============================
unicorn.conf
listen "127.0.0.1:8080"
# FAIL listen "/home/rails/tmp/sockets/unicorn.flossfish.sock"
worker_processes 4
user "rails"
working_directory "/home/rails"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/logs/error.log"
stdout_path "/home/unicorn/logs/access.log"
timeout 30
----------------------------------------
netstat -plnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 21572/unicorn.conf
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 21546/nginx.conf
Grep nginx
ps -ef | grep nginx
root 9993 9242 0 Oct14 pts/2 00:00:00 tail -100f /var/log/nginx/error.log
root 21546 1 0 14:37 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
www-data 21549 21546 0 14:37 ? 00:00:00 nginx: worker process
www-data 21550 21546 0 14:37 ? 00:00:00 nginx: worker process
www-data 21551 21546 0 14:37 ? 00:00:00 nginx: worker process
www-data 21552 21546 0 14:37 ? 00:00:00 nginx: worker process
grep unicorn
ps -ef | grep unicorn
root 20731 9242 0 13:52 pts/2 00:00:00 tail -f /home/unicorn/logs/error.log
root 21572 1 0 14:38 ? 00:00:00 unicorn master -D -c /home/unicorn/unicorn.conf -E production
rails 21575 21572 1 14:38 ? 00:00:04 unicorn worker[0] -D -c /home/unicorn/unicorn.conf -E production
rails 21578 21572 1 14:38 ? 00:00:04 unicorn worker[1] -D -c /home/unicorn/unicorn.conf -E production
rails 21580 21572 1 14:38 ? 00:00:04 unicorn worker[2] -D -c /home/unicorn/unicorn.conf -E production
rails 21583 21572 1 14:38 ? 00:00:04 unicorn worker[3] -D -c /home/unicorn/unicorn.conf -E production
-------------------------------------------------------
lsof -i :
nginx 16954 root 6u IPv4 131527 0t0 TCP *:http (LISTEN)
nginx 16957 www-data 6u IPv4 131527 0t0 TCP *:http (LISTEN)
nginx 16958 www-data 6u IPv4 131527 0t0 TCP *:http (LISTEN)
nginx 16959 www-data 6u IPv4 131527 0t0 TCP *:http (LISTEN)
nginx 16959 www-data 9u IPv4 132064 0t0 TCP 104.236.247.33:http->118.101.25.229:54644 (ESTABLISHED)
nginx 16959 www-data 10u IPv4 132065 0t0 TCP 104.236.247.33:http->118.101.25.229:54645 (ESTABLISHED)
nginx 16959 www-data 14u IPv4 132074 0t0 TCP 104.236.247.33:http->112.208.71.167.pldt.net:62601(ESTABLISHED)
nginx 16960 www-data 6u IPv4 131527 0t0 TCP *:http (LISTEN)
ruby 16984 root 10u IPv4 131638 0t0 TCP localhost:http-alt (LISTEN)
ruby 16987 rails 10u IPv4 131638 0t0 TCP localhost:http-alt (LISTEN)
ruby 16990 rails 10u IPv4 131638 0t0 TCP localhost:http-alt (LISTEN)
ruby 16993 rails 10u IPv4 131638 0t0 TCP localhost:http-alt (LISTEN)
ruby 16996 rails 10u IPv4 131638 0t0 TCP localhost:http-alt (LISTEN)
提前感谢您对此问题的任何帮助。
答案 0 :(得分:1)
谢谢大家。事实证明这是一个rails /权限问题。除了独角兽访问日志以及我发现问题的地方之外,我几乎无处不在。我认为最终当服务器被退回时我重新启动了rails / unicorn进程并在root用户下预编译了rails资产,这在/ tmp / cache / ....引起了一些文件夹权限问题。我设置了那些权限,chowed和viola所说的一切再次工作! -