# Nginx #

## Install nginx normally
passenger-install-nginx-module

## Changes to nginx configuration ##

# Up the maximum size allowed for requests (allows us to POST large log files)
client_max_body_size 100M;

# Increase the http timeout above 60 seconds; necessary for large uploads
client_body_timeout 90;

# Transmit all of the .gz files under log_files as plain/text (renders then inside the browser)
location ~* log_files.*?\.gz$ {
    types { text/plain gz; }
    add_header Content-Encoding gzip;
}

# Nginx #

## How to upgrade passenger and nginx

# Download the nginx version to be installed

    cd /Users/square
    curl http://nginx.org/download/nginx-1.2.4.tar.gz | tar xvz

# Install the passenger gem into the 1.9.3@kochiku gemset

    $ cd ~/kochiku/current
    $ gem install passenger -v 3.0.18
    $ which passenger-install-nginx-module
    # => /Users/square/.rvm/gems/ruby-1.9.3-p194@kochiku/bin/passenger-install-nginx-module

Run the passenger nginx install

    rvmsudo passenger-install-nginx-module

Select the advanced install (number 2)
Provide the path the nginx source (/Users/square/nginx-1.2.4)
Use the default install dir (/opt/nginx)
Ensure that nginx is configured with the following additional options:

    --with-http_gzip_static_module --with-cc-opt=-I/usr/local/include --with-ld-opt=-L/usr/local/lib

Explanation for extra options:
The http_gzip_static_module is used by kochiku to when serving the
log files. The cc-opt and ld-opt are needed on Snow Leopard to avoid
using the system's pcre install and use the one installed by Homebrew
instead. The compile fails with the system pcre.

After the new version finishes compiling tell nginx to reload

    sudo /opt/nginx/sbin/nginx -s reload

Now upgrade the passenger gem in the Kochiku repo and deploy it. That
gem is installed in a different location than the one above and doesn't
actually get used (which is ok). We bump the gem in the kochiku project
just to show what version is running on the server.

## Changes to nginx configuration ##

Nginx configuration for Kochiku on macbuild-master is at:

    /Users/square/.nginx/http/macbuild-master.local.conf

Up the maximum size allowed for requests (allows us to POST large log files)

    client_max_body_size 100M;

Increase the http timeout above 60 seconds; necessary for large uploads

    client_body_timeout 120;

Transmit all of the .gz files under log_files as plain/text (renders then inside the browser)

    location ~* log_files.*?\.gz$ {
        types { text/plain gz; }
        add_header Content-Encoding gzip;
    }

Update the documentation for upgrading nginx+passenger
Update the documentation for upgrading nginx+passenger
