Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Run OpenResty on Heroku with the Lua buildpack

NotificationsYou must be signed in to change notification settings

leafo/heroku-openresty

Repository files navigation

This is a Lua rock containing binaries for running OpenResty on Heroku. It'sdesigned to be used in conjunction with theLuabuildpack.

What it does

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.

How to use

Installing the rock

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"}

Running Nginx

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.sh

Commit everything and push to deploy. Runheroku scale web=1 if nginx doesn'tstart automatically.

Using PostgreSQL

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.

Version

  • OpenResty 1.5.11.1--with-http_postgres_module

About

Run OpenResty on Heroku with the Lua buildpack

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp