Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 7f4cf88

Browse files
committed
Merge pull request #8 from heroku/kong-0.7.0
Kong 0.7.0
2 parents 61310a5 + 2392900 commit 7f4cf88

File tree

5 files changed

+173
-132
lines changed

5 files changed

+173
-132
lines changed

.buildpacks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
https://github.com/heroku/heroku-buildpack-kong#v2.0.0
1+
https://github.com/heroku/heroku-buildpack-kong#v3.0.0
22
https://github.com/codeship/heroku-buildpack-runit.git

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Kong Heroku app
22
===============
3-
[Kong](https://getkong.org) as a [12-factor](http://12factor.net) app.
3+
[Kong 0.7.0](http://blog.mashape.com/kong-0-7-0-released/) as a [12-factor](http://12factor.net) app.
44

55
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/heroku/heroku-kong)
66

7-
Uses the [Kong buildpack](https://github.com/heroku/heroku-buildpack-kong) via [multi buildpack](https://github.com/heroku/heroku-buildpack-multi).
7+
Uses the [Kong buildpack](https://github.com/heroku/heroku-buildpack-kong).
88

99
This is pre-release software
1010
----------------------------

config/kong.yml.etlua

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ memory_cache_size: 1024
7575

7676
## Nginx configuration
7777
nginx: |
78-
user {{user}};
78+
{{user}}
7979
worker_processes auto;
8080
# On Heroku, stream into logplex
8181
# https://devcenter.heroku.com/articles/process-model#output-streams-as-logs
@@ -135,16 +135,20 @@ nginx: |
135135
lua_shared_dict cassandra_prepared 5m;
136136
lua_socket_log_errors off;
137137
{{lua_ssl_trusted_certificate}}
138-
init_by_lua '
138+
init_by_lua_block {
139139
kong = require "kong"
140140
kong.init()
141-
';
142-
init_worker_by_lua 'kong.init_worker()';
141+
}
142+
init_worker_by_lua_block {
143+
kong.init_worker()
144+
}
143145
server {
144146
server_name _;
145147
listen {{proxy_listen}};
146148
listen {{proxy_listen_ssl}} ssl;
147-
ssl_certificate_by_lua 'kong.ssl_certificate()';
149+
ssl_certificate_by_lua_block {
150+
kong.ssl_certificate()
151+
}
148152
ssl_certificate {{ssl_cert}};
149153
ssl_certificate_key {{ssl_key}};
150154
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;# omit SSLv3 because of POODLE (CVE-2014-3566)
@@ -154,8 +158,9 @@ nginx: |
154158
set $upstream_host nil;
155159
set $upstream_url nil;
156160
# Authenticate the user and load the API info
157-
access_by_lua 'kong.access()';
158-
# Proxy the request
161+
access_by_lua_block {
162+
kong.access()
163+
}
159164
# Proxy the request
160165
proxy_set_header X-Real-IP $remote_addr;
161166
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -164,22 +169,27 @@ nginx: |
164169
proxy_pass $upstream_url;
165170
proxy_pass_header Server;
166171
# Add additional response headers
167-
header_filter_by_lua 'kong.header_filter()';
172+
header_filter_by_lua_block {
173+
kong.header_filter()
174+
}
168175
# Change the response body
169-
body_filter_by_lua 'kong.body_filter()';
176+
body_filter_by_lua_block {
177+
kong.body_filter()
178+
}
170179
# Log the request
171-
log_by_lua 'kong.log()';
180+
log_by_lua_block {
181+
kong.log()
182+
}
172183
}
173184
location /robots.txt {
174185
return 200 'User-agent: *\nDisallow: /';
175186
}
176-
error_page 500 /500.html;
177-
location = /500.html {
187+
error_page 500 502 503 504 /50x;
188+
location = /50x {
178189
internal;
179-
content_by_lua '
180-
local responses = require "kong.tools.responses"
181-
responses.send_HTTP_INTERNAL_SERVER_ERROR("An unexpected error occurred")
182-
';
190+
content_by_lua_block {
191+
require("kong.core.error_handlers")(ngx)
192+
}
183193
}
184194
}
185195
server {
@@ -188,16 +198,16 @@ nginx: |
188198
client_body_buffer_size 10m;
189199
location / {
190200
default_type application/json;
191-
content_by_lua '
201+
content_by_lua_block {
192202
ngx.header["Access-Control-Allow-Origin"] = "*"
193203
if ngx.req.get_method() == "OPTIONS" then
194204
ngx.header["Access-Control-Allow-Methods"] = "GET,HEAD,PUT,PATCH,POST,DELETE"
195205
ngx.header["Access-Control-Allow-Headers"] = "Content-Type"
196206
ngx.exit(204)
197207
end
198208
local lapis = require "lapis"
199-
lapis.serve("kong.api.app")
200-
';
209+
lapis.serve "kong.api.app"
210+
}
201211
}
202212
location /nginx_status {
203213
internal;

config/kong_DEVELOPMENT.yml

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,69 @@
1-
# Kong app config template
2-
3-
## Custom plugins on this server
1+
---
42
custom_plugins:
53
- hello-world-header
64
- ndfd-xml-as-json
75
- librato-analytics
8-
9-
## The Kong working directory
10-
## (Make sure you have read and write permissions)
116
nginx_working_dir: /usr/local/var/kong
12-
13-
## Port configuration
14-
proxy_listen: "0.0.0.0:8000"
15-
proxy_listen_ssl: "0.0.0.0:8543"
16-
admin_api_listen: "0.0.0.0:8001"
17-
cluster_listen: "0.0.0.0:7946"
18-
19-
## Specify the DAO to use
20-
database: cassandra
21-
22-
## Databases configuration
7+
cluster:
8+
profile: local
239
cassandra:
24-
contact_points:
25-
- "127.0.0.1:9042"
26-
keyspace: "heroku_kong_dev"
27-
28-
## SSL Settings
29-
## (Uncomment the two properties below to set your own certificate)
30-
# ssl_cert_path: /path/to/certificate.pem
31-
# ssl_key_path: /path/to/certificate.key
32-
33-
## Sends anonymous error reports
34-
send_anonymous_reports: false
35-
36-
## In-memory cache size (MB)
37-
memory_cache_size: 128
38-
39-
## Nginx configuration
10+
keyspace: heroku_kong_dev
4011
nginx: |
41-
user {{user}};
12+
{{user}}
4213
worker_processes auto;
4314
error_log logs/error.log debug;
4415
daemon on;
16+
4517
worker_rlimit_nofile {{auto_worker_rlimit_nofile}};
18+
4619
env KONG_CONF;
4720
env PATH;
4821
env LIBRATO_USER;
4922
env LIBRATO_TOKEN;
23+
5024
events {
5125
worker_connections {{auto_worker_connections}};
5226
multi_accept on;
5327
}
28+
5429
http {
5530
resolver {{dns_resolver}} ipv6=off;
5631
charset UTF-8;
32+
5733
access_log logs/access.log;
58-
access_log off;
34+
access_log on;
35+
5936
# Timeouts
6037
keepalive_timeout 60s;
6138
client_header_timeout 60s;
6239
client_body_timeout 60s;
6340
send_timeout 60s;
41+
6442
# Proxy Settings
6543
proxy_buffer_size 128k;
6644
proxy_buffers 4 256k;
6745
proxy_busy_buffers_size 256k;
6846
proxy_ssl_server_name on;
47+
6948
# IP Address
7049
real_ip_header X-Forwarded-For;
7150
set_real_ip_from 0.0.0.0/0;
7251
real_ip_recursive on;
52+
7353
# Other Settings
7454
client_max_body_size 0;
7555
underscores_in_headers on;
7656
reset_timedout_connection on;
7757
tcp_nopush on;
58+
7859
################################################
7960
# The following code is required to run Kong #
8061
# Please be careful if you'd like to change it #
8162
################################################
63+
8264
# Lua Settings
83-
lua_package_path ';;';
84-
lua_code_cache on;
65+
lua_package_path './kong/?.lua;;';
66+
lua_code_cache off;
8567
lua_max_running_timers 4096;
8668
lua_max_pending_timers 16384;
8769
lua_shared_dict reports_locks 100k;
@@ -92,75 +74,105 @@ nginx: |
9274
lua_shared_dict cassandra_prepared 5m;
9375
lua_socket_log_errors off;
9476
{{lua_ssl_trusted_certificate}}
95-
init_by_lua '
77+
78+
init_by_lua_block {
9679
kong = require "kong"
9780
kong.init()
98-
';
99-
init_worker_by_lua 'kong.init_worker()';
81+
}
82+
83+
init_worker_by_lua_block {
84+
kong.init_worker()
85+
}
86+
10087
server {
10188
server_name _;
10289
listen {{proxy_listen}};
10390
listen {{proxy_listen_ssl}} ssl;
104-
ssl_certificate_by_lua 'kong.ssl_certificate()';
91+
92+
ssl_certificate_by_lua_block {
93+
kong.ssl_certificate()
94+
}
95+
10596
ssl_certificate {{ssl_cert}};
10697
ssl_certificate_key {{ssl_key}};
10798
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;# omit SSLv3 because of POODLE (CVE-2014-3566)
99+
108100
location / {
109101
default_type 'text/plain';
102+
110103
# These properties will be used later by proxy_pass
111104
set $upstream_host nil;
112105
set $upstream_url nil;
106+
113107
# Authenticate the user and load the API info
114-
access_by_lua 'kong.access()';
115-
# Proxy the request
108+
access_by_lua_block {
109+
kong.access()
110+
}
111+
116112
# Proxy the request
117113
proxy_set_header X-Real-IP $remote_addr;
118114
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
119115
proxy_set_header X-Forwarded-Proto $scheme;
120116
proxy_set_header Host $upstream_host;
121117
proxy_pass $upstream_url;
122118
proxy_pass_header Server;
119+
123120
# Add additional response headers
124-
header_filter_by_lua 'kong.header_filter()';
121+
header_filter_by_lua_block {
122+
kong.header_filter()
123+
}
124+
125125
# Change the response body
126-
body_filter_by_lua 'kong.body_filter()';
126+
body_filter_by_lua_block {
127+
kong.body_filter()
128+
}
129+
127130
# Log the request
128-
log_by_lua 'kong.log()';
131+
log_by_lua_block {
132+
kong.log()
133+
}
129134
}
135+
130136
location /robots.txt {
131137
return 200 'User-agent: *\nDisallow: /';
132138
}
133-
error_page 500 /500.html;
134-
location = /500.html {
139+
140+
error_page 500 502 503 504 /50x;
141+
142+
location = /50x {
135143
internal;
136-
content_by_lua '
137-
local responses = require "kong.tools.responses"
138-
responses.send_HTTP_INTERNAL_SERVER_ERROR("An unexpected error occurred")
139-
';
144+
content_by_lua_block {
145+
require("kong.core.error_handlers")(ngx)
146+
}
140147
}
141148
}
149+
142150
server {
143151
listen {{admin_api_listen}};
152+
144153
client_max_body_size 10m;
145154
client_body_buffer_size 10m;
155+
146156
location / {
147157
default_type application/json;
148-
content_by_lua '
158+
content_by_lua_block {
149159
ngx.header["Access-Control-Allow-Origin"] = "*"
150160
if ngx.req.get_method() == "OPTIONS" then
151161
ngx.header["Access-Control-Allow-Methods"] = "GET,HEAD,PUT,PATCH,POST,DELETE"
152162
ngx.header["Access-Control-Allow-Headers"] = "Content-Type"
153163
ngx.exit(204)
154164
end
155165
local lapis = require "lapis"
156-
lapis.serve("kong.api.app")
157-
';
166+
lapis.serve "kong.api.app"
167+
}
158168
}
169+
159170
location /nginx_status {
160171
internal;
161-
access_log off;
172+
access_log on;
162173
stub_status;
163174
}
175+
164176
location /robots.txt {
165177
return 200 'User-agent: *\nDisallow: /';
166178
}

0 commit comments

Comments
 (0)