使用带有 private_pub gem 的 Nginx 1.6 这是我的配置文件:
private_pub.ru
# Run with: rackup private_pub.ru -s thin -E production
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"
Faye::WebSocket.load_adapter('thin')
PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
run PrivatePub.faye_app
Private_pub.yml
development:
server: "http://localhost:9292/faye/faye"
secret_token: "secret"
test:
server: "http://localhost:9292/faye/faye"
secret_token: "secret"
production:
server: "http://xxxxx.com/faye/faye"
secret_token: "my secret token"
signature_expiration: 3600 # one hour
在我的 Nginx.conf 中
location /faye {
proxy_pass http://0.0.0.0:9292;
break;
}
该服务正在运行,但真的很慢,我在 safari 上遇到了这些错误:
WebSocket 连接到“ws://xxxxx.com/faye”失败:意外响应代码:400 加载资源失败:服务器响应状态为 404(未找到)加载资源失败:服务器响应状态为502错误的网关)
有什么想法吗?