Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 1.94 KB

nginx_unicorn.md

File metadata and controls

47 lines (30 loc) · 1.94 KB

Drawing NGINX + Unicorn

Introduction


**Nginx**

It is a pure web server that's intended for serving up static content and/or redirecting the request to another socket to handle the request.

Unicorn

It is a Rack web server and only intended to host a 'Rack App' which is usually generating dynamic content. Rack apps can also serve up static content but it's less efficient than most other traditional web servers.

It 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. - http://unicorn.bogomips.org/

Common Setup


Most RoR setups use a combination of both traditional web servers and Rack servers to apply the best of both of their capabilities. Nginx is incredibly fast at request redirection through proxy balancing and serving up static content. Unicorn is quite capable of processing HTTP headers and balancing inbound requests to Ruby for processing.

Request routing

Incoming request are processed by nginx.conf. nginx.conf includes other conf files by below line.

include /etc/nginx/sites-enabled/*;

sites-enabled folder has symlinks to actual config files that come from the project folder or sites-available.

Basic commands

$ /etc/init.d/nginx -h

Usage: nginx {start|stop|restart|reload|force-reload|status|configtest}

# service can be used to avoid /etc/init.d
$ sudo service nginx start

Sources