我们如何在Apache中做以下Nginx配置?
基本上代理到Unix套接字而不是负载均衡端口。我希望独角兽处理负载平衡,而不是Apache。
upstream unicorn_server {
server unix:/home/prats/public_html/myapp/current/tmp/sockets/unicorn.sock
fail_timeout=0;
}
server {
...
...
...
location / {
...
...
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://unicorn_server;
break;
}
...
...
}
}
在搜索了相当长的一段时间之后,我得出结论,通过套接字使用Apache2 + Unicorn是不可能的。我得到的最远的是使用mod_fastcgi上的套接字文件,独角兽提供,但我得到403禁止尝试访问页面时。FastCGI似乎需要一个不同于Unicorn使用的协议。如果你必须在Apache中使用独角兽,请坚持使用Mark Kolesar的解决方案。注意您可能会遇到问题(取自http://rubyforge.org/pipermail/mongrel-unicorn/2011-July/001057.html):
)Apache + Unicorn仍然不受支持,因为(据任何人所知),它不能完全缓冲响应和请求以完全隔离麒麟从缓慢的客户端有害影响。
ProxyRequests Off
ProxyPass/stylesheets/!
ProxyPass/javascripts/!
ProxyPass/images/!
ProxyPass/http://example.com:8080/
ProxyPassReverse/http://example.com:8080/
不能在中间使用unixcat吗?将代理传递到本地主机已安装Xinetd + unixcat/etc/xinetd.d/独角兽控股:
service livestatus
{
type = UNLISTED
port = someport
socket_type = stream
protocol = tcp
wait = no
cps = 100 3
instances = 500
per_source = 250
flags = NODELAY
user = someone
server = /usr/bin/unixcat
server_args = /var/run/unicorn/mysocket
only_from = 127.0.0.1
disable = no
}