How can we do the below Nginx configuration in Apache?
Basically proxying to a Unix socket instead of a load balanced port. I want that Unicorn handle the load balancing instead of Apache.upstream unicorn_server {
server 开发者_Go百科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;
}
...
...
}
}
After having searched for quite a while, I came to the conclusion that using Apache2 + Unicorn via sockets is not possible. The farthest I got was using mod_fastcgi on the socket file that unicorn provides, but I got 403 Forbidden when trying to access the page. It seems that FastCGI requires a different protocol than the one Unicorn uses. Stick with the solution from Mark Kolesar if you have to use Unicorn with Apache. Be aware that you might run into problems (taken from http://rubyforge.org/pipermail/mongrel-unicorn/2011-July/001057.html):
Apache + Unicorn is still unsupported since (as far as anybody knows), it doesn't fully buffer responses and requests to completely isolate Unicorn from the harmful effects of slow clients.
ProxyRequests Off
ProxyPass /stylesheets/ !
ProxyPass /javascripts/ !
ProxyPass /images/ !
ProxyPass / http://example.com:8080/
ProxyPassReverse / http://example.com:8080/
Can't you do it using unixcat in between? Having the proxypass to localhost:something xinetd + unixcat installed /etc/xinetd.d/unicorn holding:
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
}
精彩评论