Nginx

Nginx Thin.Sock 未找到錯誤

  • March 20, 2015

3 個文件的集群(Nginx 的 err.log、chat.yml、chat.conf):

錯誤日誌:

2015/03/19 15:05:50 [crit] 1535#0: *79 connect() to unix:/var/www/chat/public/tmp/sockets/thin.0.sock failed (2: No such file or directory) while connecting to upstream, client: 162.243.6.35, server: chat.stackin.money, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/chat/public/tmp/sockets/thin.0.sock:/", host: "chat.stackin.money"
2015/03/19 15:05:50 [crit] 1535#0: *79 connect() to unix:/var/www/chat/public/tmp/sockets/thin.1.sock failed (2: No such file or directory) while connecting to upstream, client: 162.243.6.35, server: chat.stackin.money, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/chat/public/tmp/sockets/thin.0.sock:/", host: "chat.stackin.money"

聊天.conf:

upstream stackin_money {
 ip_hash;
 server unix:/var/www/chat/public/tmp/sockets/thin.0.sock max_fails=1 fail_timeout=15s;
 server unix:/var/www/chat/public/tmp/sockets/thin.1.sock max_fails=1 fail_timeout=15s;
}

server {

 listen 80;
 server_name chat.stackin.money;

 location / {
   proxy_pass http://stackin_money;
   proxy_set_header HOST $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 }

 root /var/www/chat/public;

# access_log /var/log/nginx/access.log;
# error_log /var/log/nginx/error.log;

}

聊天.yml:

user: root
group: root
pid: tmp/pids/thin.pid
timeout: 30
wait: 30
log: /var/log/thin/thin.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
servers: 2
onebyone: true
threaded: true
no-epoll: true
daemonize: true
socket: tmp/sockets/thin.sock
chdir: /var/www/chat/public
tag: chat aux

因此,我正在執行一個 sinatra 應用程序,該應用程序使用 Thin 作為其伺服器進行實時聊天,並且由於我希望它在子域上執行,因此我使用 Nginx 進行反向代理。但是,我在使用 Nginx 或 Thin(從 Nginx 的錯誤日誌中得到錯誤)時遇到了一些問題,它無法找到我在此處(下)的 Thin 套接字的 chat.yml 中指定的文件或目錄。它是真的,它根本不存在。

有什麼幫助嗎?提前致謝

查看**/var/www/chat/public/tmp/sockets/** - Thin.0.sock 真的存在嗎?據我所知,Thin 只支持 TCP 套接字,不支持 Unix 套接字。如果您從 Unicorn 特定的範例中複製了 Unix 套接字,那就可以解釋了,因為 Unicorn 確實支持它們。

我建議將上游定義塊更改為說server http://127.0.0.1:4567或類似的東西(無論瘦程序使用什麼埠)。

引用自:https://serverfault.com/questions/676893