我一收到此錯誤:的Rails 5應用與彪馬和Nginx的 - 111:連接被拒絕在連接到上游客戶
2016/09/29 01:05:39 [error] 7169#0: *3 connect() to unix:/home/deploy/tasks/shared/tmp/sockets/puma.sock failed (111: Connection refused) while connecting to upstream, client: 99.254.197.158, server: localhost, request: "GET/HTTP/1.1", upstream: "http://unix:/home/deploy/tasks/shared/tmp/sockets/puma.sock:/", host: "ec2-54-88-181-57.compute-1.amazonaws.com"
當嘗試使用這個網址我的應用程序:
http://ec2-54-88-181-57.compute-1.amazonaws.com/
瀏覽器也呈現出這樣的信息:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
但是我直接在端口3使用彪馬當我能夠訪問我的應用程序使用000這個URL:
http://ec2-54-88-181-57.compute-1.amazonaws.com:3000/
,我能夠通過應用這種方式的所有頁面瀏覽。
下面是我的一些配置文件:
$ ls -l /etc/nginx/sites-enabled
total 0
lrwxrwxrwx 1 root root 34 Sep 28 22:46 default -> /etc/nginx/sites-available/default
$ sudo cat /etc/nginx/nginx.conf
[sudo] password for deploy:
user root; #www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
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;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
$ sudo cat /etc/nginx/sites-available/default
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:/home/deploy/tasks/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name localhost;
root /home/deploy/tasks/current/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
服務器上的端口80,22和3000聽(彪馬)
$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN
tcp 0 280 172.31.51.143:22 99.254.197.158:60843 ESTABLISHED
tcp 0 0 172.31.51.143:22 99.254.197.158:60842 ESTABLISHED
tcp 0 0 172.31.51.143:59545 172.31.47.0:5432 ESTABLISHED
tcp 0 0 172.31.51.143:59544 172.31.47.0:5432 ESTABLISHED
tcp6 0 0 :::22 :::* LISTEN
udp 0 0 0.0.0.0:55159 0.0.0.0:*
udp 0 0 0.0.0.0:68 0.0.0.0:*
udp6 0 0 :::12784 :::*
的Nginx和彪馬都在運行。
$ ps -ef | grep nginx
root 1644 1586 0 01:21 pts/0 00:00:00 sudo tail -f /var/log/nginx/error.log
root 1645 1644 0 01:21 pts/0 00:00:00 tail -f /var/log/nginx/error.log
root 1698 1 0 01:39 ? 00:00:00 nginx: master process /usr/sbin/nginx
root 1701 1698 0 01:39 ? 00:00:00 nginx: worker process
root 1702 1698 0 01:39 ? 00:00:00 nginx: worker process
root 1703 1698 0 01:39 ? 00:00:00 nginx: worker process
root 1704 1698 0 01:39 ? 00:00:00 nginx: worker process
deploy 1736 1309 0 02:13 pts/1 00:00:00 grep nginx
$ ps -ef | grep puma
deploy 1564 1 0 01:20 ? 00:00:00 puma 3.6.0 (tcp://0.0.0.0:3000) [20160928212850]
deploy 1571 1564 0 01:20 ? 00:00:01 puma: cluster worker 0: 1564 [20160928212850]
我正在使用Capistrano部署到AWS EC2 Ubuntu 14.04服務器。 沒有與部署相關的錯誤。
我提取了所有發現的博客/博文,但是這些解決方案都沒有爲我工作到目前爲止。
爲了讓Nginx服務器正常工作,我將嘗試下一步?
你能分享錯誤/服務器日誌... – Milind
其中哪一個? Ubuntu的@ IP-172-31-51-143:在/ var /日誌$ LS -1 alternatives.log 容易 auth.log auth.log.1 boot.log BTMP 雲init.log 雲INIT-output.log DIST升級 dmesg的 dmesg.0 dmesg.1.gz dmesg.2.gz dmesg.3.gz dmesg.4.gz dpkg.log 的fsck 克恩。日誌 kern.log.1 風景 lastlog nginx PostgreSQL的 系統日誌 syslog.1 syslog.2.gz syslog.3.gz syslog.4.gz syslog.5.gz 的udev 無人蔘與升級 新貴 wtmp文件 –