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"
聊天配置文件:
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
因此,我正在运行一个使用 Thin 作为实时聊天服务器的 Sinatra 应用程序,由于我希望它在子域上运行,因此我使用 Nginx 进行反向代理。但是,我在使用 Nginx 或 Thin 时遇到了一些问题(从 Nginx 的错误日志中得到错误),它找不到我在 Thin 套接字的 chat.yml 中指定的文件或目录(如下)。是的,它根本不在那里。
有什么帮助吗?提前致谢
答案1
在看/var/www/聊天/公共/tmp/插座/- thin.0.sock 真的存在吗?据我所知,Thin 仅支持 TCP 套接字,不支持 Unix 套接字。如果您从特定于 Unicorn 的示例中复制了 Unix 套接字,那就可以解释它了,因为 Unicorn 确实支持它们。
我建议将上游定义块更改为server http://127.0.0.1:4567
类似这样的东西(无论 Thin 进程使用什么端口)。