This buildpack was forked from https://github.com/ryandotsmith/nginx-buildpack but is taking a slightly different approach by now.
The basic idea:
The original repo was focused on running nginx AND another app server in the target dyno, and synchronizing start and exit for both. This version is for nginx alone, serving static content or proxying or whatever.
The versions of nginx, PCRE, and the "headers_more" module are configured in scripts/build_nginx.sh
All are fetched from their authoritative homes (URLs configured in build_nginx.sh as well). Build is cached in the app cache so it should only compile nginx the first time you run it.
To create a new app using this buildpack, clone your app's repository and make sure you have a config/nginx.conf.erb. From within the clone:
$ heroku create --buildpack http://github.com/Thinkful/nginx-buildpack.git $ git push heroku master
(heroku magically creates a remote called 'heroku')
You should see the buildpack download, build, and install nginx and its dependencies.
The built files will be cached by Heroku so it won't build every time you push a change to your app. To clear the cache and force a rebuild (say, for a new version of nginx) you can install the heroku-repo tool:
It adds a command to the heroku command line app to flush the buildpack cache:
$ heroku repo:purge_cache --app <appname>
The file 'config/nginx.conf.erb' will be processed through
nginx.conf. The only thing that
erb is really
getting you is the expansion of the PORT variable but that's
necessary. If you want to change the buildpack to use something
besides erb, look in bin/start-nginx and scripts/build_nginx.sh
NGINX will output the following style of logs:
You can correlate this id with your Heroku router logs:
at=info method=GET path=/ host=salty-earth-7125.herokuapp.com request_id=e2c79e86b3260b9c703756ec93f8a66d fwd="184.108.40.206" dyno=web.1 connect=1ms service=8ms status=200 bytes=21
You can configure NGINX's
worker_processes directive via the
NGINX_WORKERS environment variable.
For example, to set your
NGINX_WORKERS to 8 on a PX dyno:
$ heroku config:set NGINX_WORKERS=8
You can provide your own NGINX config by creating a file named
nginx.conf.erb in the config directory of your app. Start by
copying the buildpack's default config
See scripts/build_nginx.sh for the build steps. Configuring is as easy as changing the "./configure" options.
Bill Gribble firstname.lastname@example.org
Copyright (c) 2014 Thinkful
Copyright (c) 2013 Ryan R. Smith
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.
Copy the snippet above into CLI.