- Notifications
You must be signed in to change notification settings - Fork23
leafo/heroku-openresty
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is a Lua rock containing binaries for running OpenResty on Heroku. It'sdesigned to be used in conjunction with theLuabuildpack.
In addition to a pre compiled openresty, some scripts to start nginx areincluded. nginx doesn't support passing in port through argument or readingfrom environment variable so we preprocess the config file.
Anything matching${{NAME}} is replaced with the environment variableNAMEinside of your nginx configuration config. (note: doesn't apply to includedfiles)
Thestart_nginx.sh script will read innginx.conf, compile it tonginx.conf.compiled then start nginx. It takes two optional arguments, analternative path for the config as the first and and an alternative rootdirectory to run the server from. The config must be specified relative to theroot.
Thedaemon off; directive must be added to the config for the entire thing towork.
Create a new app with theLua buildpack.
$ heroku create --buildpack http://github.com/leafo/heroku-buildpack-lua.git
Add to your rockspec dependencies:
dependencies= {"https://raw.github.com/leafo/heroku-openresty/master/heroku-openresty-1.2.8.6-1.rockspec"}
These directions are for manually running Nginx, if you prefer to use aframework then I recommend checking out:http://leafo.net/lapis.
Create a basicnginx.conf, this is the one from the OpenResty guide (with theaddition ofdaemon off and${{PORT}}):
worker_processes 1;error_log logs/error.log;daemon off;events { worker_connections 1024;}http { server { listen ${{PORT}}; location / { default_type text/html; content_by_lua ' ngx.say("<p>hello, world</p>") '; } }}Create aProcfile:
web: start_nginx.shCommit everything and push to deploy. Runheroku scale web=1 if nginx doesn'tstart automatically.
This build includes thePostgres nginxmodule, all you need todo is pass in your database configuration.
First add a database if you haven't added one already:
heroku addons:add heroku-postgresql:dev
This will set an environment variable inside of your application that lookssomething like this:
HEROKU_POSTGRESQL_ROSE_URL="postgres://user:password@database.domain.com/databasename"The nginx config expects a slightly different format, but no worries the configpreprocessor has a filter to convert to the correct format.
Add the database to your config like so: (notice the prefixpg)
http { upstream database { postgres_server ${{pg HEROKU_POSTGRESQL_ROSE_URL}}; }}That's it, your application can now talk to Postgres through thedatabaseupstream.
- OpenResty 1.5.11.1
--with-http_postgres_module
About
Run OpenResty on Heroku with the Lua buildpack
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.