1- # Kong app config template
2-
3- # # Custom plugins on this server
1+ ---
42custom_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)
116nginx_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
239cassandra :
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
4011nginx : |
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