2016-09-29 58 views
1

我一收到此錯誤:的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服務器正常工作,我將嘗試下一步?

+0

你能分享錯誤/服務器日誌... – Milind

+0

其中哪一個? 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文件 –

回答

1

我放棄了AWS EC2實例,並使用我升級到16.04的Ubuntu 14.04實現重新創建實例。我遵循嚴格的指導在這裏找到

http://codepany.com/blog/rails-5-puma-capistrano-nginx-jungle-upstart/ 和相同的博客鏈接。

現在的Nginx和彪馬正確一起工作,我的應用程序完美的運行在這裏:

http://ec2-54-159-156-217.compute-1.amazonaws.com/ 唯一的區別形成的準則是,我不停的AWS RDS實例數據庫。我在生產服務器上使用了RVM,儘管我在我的Mac上使用了RBENV。我使用Ubuntu的用戶(如root)進行部署,因爲我懷疑所有與權限有關的問題,但我不知道如何解決這些問題。

許多錯誤早期遇到的努力開始插槽正確彪馬,使其與Nginx的工作,尤其是在

帽生產部署 分別與生成的祕密,並把該值在此時,相應的文件,而不是重新啓動。對我來說,它最好的寫在/ etc/environment文件中。

我也在文件/ etc/ssh/sshd_config中進行了更改,以便通過ssh獲得root或ubuntu訪問權限。在這件事情這個鏈接

https://forums.aws.amazon.com/thread.jspa?threadID=86876 是非常有用的。

相關問題