2017-02-27 69 views
4

我遵循ruby on rails一個應用程序單擊部署。數據庫做得很好,即使我檢查鐵軌控制檯一切工作正常連接()到unix:/var/run/unicorn.sock失敗(111:連接被拒絕),同時連接到上游

017/02/26 15:34:17 [error] 18564#0: *31 connect() to unix:/var/run/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.52.156.57, server: _, request: "GET/HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock:/", host: "188.166.157.124" 
2017/02/26 15:35:42 [error] 32360#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 119.155.34.115, server: _, request: "GET/HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "188.166.157.124" 
2017/02/26 15:42:38 [error] 6296#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 119.152.140.90, server: _, request: "GET/HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock/", host: "188.166.157.124" 

uncorn.conf是

listen "unix:/var/run/unicorn.sock" 
worker_processes 4 
user "rails" 
working_directory "/home/rails/company_startup" 
pid "/var/run/unicorn.pid" 
stderr_path "/var/log/unicorn/unicorn.log" 
stdout_path "/var/log/unicorn/unicorn.log" 

nginx的是

upstream app_server { 
server unix:/var/run/unicorn.sock fail_timeout=0; 

}

server { 
listen 80; 
root /home/rails/nehbor-webserver/public; 
server_name _; 
index index.htm index.html; 
client_max_body_size 1M; 
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; 
} 
} 

回答

2

按照unicorn documentation ,我認爲您應該從配置中的listen方法中刪除unix部分,並將其更改爲listen "/var/run/unicorn.sock"

listen 3000 # listen to port 3000 on all TCP interfaces 
listen "127.0.0.1:3000" # listen to port 3000 on the loopback interface 
listen "/path/to/.unicorn.sock" # listen on the given Unix domain socket 
listen "[::1]:3000" # listen to port 3000 on the IPv6 loopback interface 
0

總之,nginx試圖重新指向你的應用程序,但它不能。基本配置的東西和結構之外,我認爲最常見的問題是關係到:

  • 港口
  • 插座
  • 和我(使用AWS EC2),我用的是這是通過鏈接域我的DNS註冊表中的一個cname記錄。 ip改變了哪個改變了域名服務器名稱,我的記錄沒有更新。我只是將它從cname記錄名稱更改爲我的新彈性域名。
相關問題