NGINX is built during initial deployment, rather than using a prebuilt binary. The binary is cached between deploys.

NGINX logs are sent directly to stderr rather than to the filesystem. This results in faster log delivery to Heroku logplex, and doesn't gradually fill the filesystem.

Signals are handled gracefully by the wrapper script, allowing both the app and NGINX to stop properly on dyno shutdown.

PORT is overridden to refer to the UNIX domain socket, so the application can detect whether it's running under NGINX or directly. This is especially because NGINX can be enabled or disabled at run-time by toggling NGINX_ENABLED.

Versions

These versions are tunable by setting NGINX_VERSION and NGINX_PCRE_VERSION in the app config, so you can update even if the buildpack hasn't been updated yet.

Installation and use

This buildpack has been optimized for static file serving out of the dist
folder in your application. You can run this alone or in combination with
another buildpack such as Node.js to compile your app into this directory.

Customizable NGINX Config

You can provide your own NGINX config by creating a file named config/nginx.conf.erb in your app. Start by copying the buildpack's default config file.

Alternatively, if you like the defaults, you can add a file config/nginx-local.conf and it will be included automatically.

Patched Logging

This buildpack patches NGINX to send the access log directly to stderr, which is not a feature NGINX provides normally. If you override the default config and want to make use of this logging feature, use the following:

error_log stderr;
http {
access_log error;
}

This instructs NGINX to send the error log to stderr (this is provided by NGINX upstream) and then to send the access log to the error log output (this is provided by the patch).

License

Copyright (c) 2013 Ryan R. Smith

Copyright (c) 2014 Aron Griffis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.