Reputation: 7281
Most of the tutorials out there show how to configure nginx web server as a proxy to a unicorn ruby application server when they are on the same server; a result is that they both communicate via unix sockets. How can I configure both of them if they are on different servers.
Upvotes: 3
Views: 427
Reputation: 6346
The basic setup is as follows:
In your unicorn config you'll want to listen to a TCP port rather than a unix socket:
listen 80, :tcp_nopush => true
Likewise, in your Nginx configuration simply proxy requests to a remote server:
upstream backend {
ip_hash;
server backend1.example.com;
server backend2.example.com;
server backend3.example.com down;
server backend4.example.com;
}
You should also checkout http://unicorn.bogomips.org/examples/nginx.conf for unicorn-tailored nginx configuration.
Upvotes: 0
Reputation: 15530
Unicorn designed to serve fast clients only:
unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels. Slow clients should only be served by placing a reverse proxy capable of fully buffering both the the request and response in between unicorn and slow clients.
How does it work within load balancing between multi nodes environment? The answer is to have application nodes Nginx+Unicorn (connect via Unix Domain Socket) and top level Nginx as load balancer on separate node.
Upvotes: 2