Advertisement
Guest User

Untitled

a guest
Dec 26th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.87 KB | None | 0 0
  1. ######
  2. ## Kong configuration file. All commented values are default values.
  3. ## Uncomment and update a value to configure Kong to your needs.
  4. ##
  5. ## Lines starting with `##` are comments.
  6. ## Lines starting with `#` are properties that can be updated.
  7. ## Beware of YAML formatting for nested properties.
  8.  
  9. ######
  10. ## Additional plugins that this node needs to load.
  11. ## If you want to load custom plugins that are not supported by Kong, uncomment and update
  12. ## this property with the names of the plugins to load.
  13. ## Plugins will be loaded from the kong.plugins.{name}.* namespace.
  14. # custom_plugins:
  15. # - hello_world
  16. # - custom_plugin2
  17. # - ...
  18.  
  19. ######
  20. ## The Kong working directory. Equivalent to nginx's prefix path.
  21. ## This is where this running nginx instance will keep server files including logs.
  22. ## Make sure it has the appropriate permissions.
  23. # nginx_working_dir: /usr/local/kong/
  24.  
  25. ######
  26. ## Address and port on which the server will accept HTTP requests, consumers will make requests on this port.
  27. # proxy_listen: "0.0.0.0:8000"
  28.  
  29. ######
  30. ## Same as proxy_listen, but for HTTPS requests.
  31. # proxy_listen_ssl: "0.0.0.0:8443"
  32.  
  33. ######
  34. ## Address and port on which the admin API will listen to. The admin API is a private API which lets you
  35. ## manage your Kong infrastructure. It needs to be secured appropriately.
  36. # admin_api_listen: "0.0.0.0:8001"
  37.  
  38. ######
  39. ## Address and port used by the node to communicate with other Kong nodes in the cluster with both UDP and
  40. ## TCP messages. All the nodes in the cluster must be able to communicate with this node on this address.
  41. ## Only IPv4 addresses are allowed (no hostnames).
  42. # cluster_listen: "0.0.0.0:7946"
  43.  
  44. ######
  45. ## Address and port used by the node to communicate with the local clustering agent (TCP only, and local only).
  46. ## Used internally by this Kong node. Only IPv4 addresses are allowed (no hostnames).
  47. # cluster_listen_rpc: "127.0.0.1:7373"
  48.  
  49. ######
  50. ## The path to the SSL certificate and key that Kong will use when listening on the `https` port.
  51. # ssl_cert_path: /path/to/certificate.pem
  52. # ssl_key_path: /path/to/certificate.key
  53.  
  54. ######
  55. ## Specify how Kong performs DNS resolution (in the `dns_resolvers_available` property) you want to use.
  56. ## Options are: "dnsmasq" (You will need dnsmasq to be installed) or "server".
  57. # dns_resolver: dnsmasq
  58.  
  59. ######
  60. ## A dictionary of DNS resolvers Kong can use, and their respective properties.
  61. ## Currently `dnsmasq` (default, http://www.thekelleys.org.uk/dnsmasq/doc.html) and `server` are supported.
  62. ## By choosing `dnsmasq`, Kong will resolve hostnames using the local `/etc/hosts` file and `resolv.conf`
  63. ## configuration. By choosing `
  64. server`, you can specify a custom DNS server.
  65. # dns_resolvers_available:
  66. # server:
  67. # address: "8.8.8.8:53"
  68. # dnsmasq:
  69. # port: 8053
  70.  
  71. ######
  72. ## Cluster settings between Kong nodes.
  73. ## For more information take a look at the Clustering Reference: https://getkong.org/docs/latest/clustering/
  74. # cluster:
  75.  
  76. ######
  77. ## Address and port used by the node to communicate with other Kong nodes in the cluster with both UDP and
  78. ## TCP messages. All the nodes in the cluster must be able to communicate with this node on this address.
  79. ## Only IPv4 addresses are allowed (no hostnames).
  80. ## The advertise flag is used to change the address that we advertise to other nodes in the
  81. ## cluster. By default, the cluster_listen address is advertised. If the cluster_listen host is "0.0.0.0",
  82. ## then the first local, non-loopback, IPv4 address will be advertised to the other nodes. However, in some
  83. ## cases (specifically NAT traversal), there may be a routable address that cannot be bound to. This flag
  84. ## enables gossiping a different address to support this.
  85. # advertise: ""
  86.  
  87. ######
  88. ## Key for encrypting network traffic within Kong. Must be a base64-encoded 16-byte key.
  89. # encrypt: "foo"
  90.  
  91. ######
  92. ## The TTL (time to live), in seconds, of a node in the cluster when it stops sending healthcheck pings, maybe
  93. ## because of a failure. If the node is not able to send a new healthcheck before the expiration, then new nodes
  94. ## in the cluster will stop attempting to connect to it on startup. Should be at least 60.
  95. # ttl_on_failure: 3600
  96.  
  97. ######
  98. ## Specify which database to use. Only "cassandra" and "postgres" are currently available.
  99. # database: cassandra
  100.  
  101. ######
  102. ## PostgreSQL configuration
  103. # postgres:
  104. # host: "127.0.0.1"
  105. # port: 5432
  106.  
  107. ######
  108. ## Name of the database used by Kong. Will be created if it does not exist.
  109. # database: kong
  110.  
  111. #####
  112. ## User authentication settings
  113. # user: ""
  114. # password: ""
  115.  
  116. ######
  117. ## Cassandra configuration (keyspace, authentication, client-to-node encryption)
  118. # cassandra:
  119. ######
  120. ## Contact points to your Cassandra cluster.
  121. # contact_points:
  122. # - "127.0.0.1:9042"
  123.  
  124. ## Port on which your cluster's peers (other than your contact_points)
  125. ## are listening on.
  126. # port: 9042
  127.  
  128. ######
  129. ## Name of the keyspace used by Kong. Will be created if it does not exist.
  130. # keyspace: kong
  131.  
  132. #####
  133. ## Connection and reading timeout (in ms).
  134. # timeout: 5000
  135.  
  136. ######
  137. ## Keyspace options. Set those before running Kong or any migration.
  138. ## Those settings will be used to create a keyspace with the desired options
  139. ## when first running the migrations.
  140. ## See http://docs.datastax.com/en/cql/3.1/cql/cql_reference/create_keyspace_r.html
  141. ######
  142. ## The name of the replica placement strategy class for the keyspace.
  143. ## Can be "SimpleStrategy" or "NetworkTopologyStrategy".
  144. # replication_strategy: SimpleStrategy
  145. ######
  146. ## For SimpleStrategy only.
  147. ## The number of replicas of data on multiple nodes.
  148. # replication_factor: 1
  149. ######
  150. ## For NetworkTopologyStrategy only.
  151. ## The number of replicas of data on multiple nodes in each data center.
  152. # data_centers:
  153. # dc1: 2
  154. # dc2: 3
  155.  
  156. #####
  157. ## Consistency level to use.
  158. ## See http://docs.datastax.com/en/cassandra/2.0/cassandra/dml/dml_config_consistency_c.html
  159. # consistency: ONE
  160.  
  161. #####
  162. ## Client-to-node TLS options.
  163. ## `enabled`: if true, will connect to your Cassandra instance using TLS.
  164. ## `verify`: if true, will verify the server certificate using the given CA file.
  165. ## `certificate_authority`: an absolute path to the trusted CA certificate in PEM format used to verify the server certificate.
  166. ## For additional SSL settings, see the ngx_lua `lua_ssl_*` directives.
  167. # ssl:
  168. # enabled: false
  169. # verify: false
  170. # certificate_authority: "/path/to/cluster-ca-certificate.pem"
  171.  
  172. ######
  173. ## Cluster authentication options. Provide a user and a password here if your cluster uses the
  174. ## PasswordAuthenticator scheme.
  175. # username: cassandra
  176. # password: cassandra
  177.  
  178. ######
  179. ## Kong will send anonymous reports to Mashape. This helps Mashape fixing bugs/errors and improving Kong.
  180. ## By default is `true`.
  181. # send_anonymous_reports: true
  182.  
  183. ######
  184. ## A value specifying (in MB) the size of the internal preallocated in-memory cache. Kong uses an in-memory
  185. ## cache to store database entities in order to optimize access to the underlying datastore. The cache size
  186. ## needs to be as big as the size of the entities being used by Kong at any given time. The default value
  187. ## is `128`, and the potential maximum value is the total size of the datastore.
  188. ## This value may not be smaller than 32MB.
  189. # memory_cache_size: 128
  190.  
  191. ######
  192. ## The NGINX configuration (or `nginx.conf`) that will be used for this instance.
  193. ## The placeholders will be computed and this property will be written as a file
  194. ## by Kong at `<nginx_working_dir>/nginx.conf` during startup.
  195. ## This file can tweaked to some extent, but many directives are necessary for Kong to work.
  196. ## /!\ BE CAREFUL
  197. nginx: |
  198. {{user}}
  199. worker_processes auto;
  200. error_log logs/error.log error;
  201. daemon on;
  202.  
  203. worker_rlimit_nofile {{auto_worker_rlimit_nofile}};
  204.  
  205. env KONG_CONF;
  206. env PATH;
  207.  
  208. events {
  209. worker_connections {{auto_worker_connections}};
  210. multi_accept on;
  211. }
  212.  
  213. http {
  214. resolver {{dns_resolver}} ipv6=off;
  215. charset UTF-8;
  216.  
  217. access_log logs/access.log;
  218. access_log off;
  219.  
  220. # Timeouts
  221. keepalive_timeout 60s;
  222. client_header_timeout 60s;
  223. client_body_timeout 60s;
  224. send_timeout 60s;
  225.  
  226. # Proxy Settings
  227. proxy_buffer_size 128k;
  228. proxy_buffers 4 256k;
  229. proxy_busy_buffers_size 256k;
  230. proxy_ssl_server_name on;
  231.  
  232. # IP Address
  233. real_ip_header X-Forwarded-For;
  234. set_real_ip_from 0.0.0.0/0;
  235. real_ip_recursive on;
  236.  
  237. # Other Settings
  238. client_max_body_size 0;
  239. underscores_in_headers on;
  240. reset_timedout_connection on;
  241. tcp_nopush on;
  242.  
  243. ################################################
  244. # The following code is required to run Kong #
  245. # Please be careful if you'd like to change it #
  246. ################################################
  247.  
  248. # Lua Settings
  249. lua_package_path ';;';
  250. lua_code_cache on;
  251. lua_max_running_timers 4096;
  252. lua_max_pending_timers 16384;
  253. lua_shared_dict reports_locks 100k;
  254. lua_shared_dict cluster_locks 100k;
  255. lua_shared_dict cluster_autojoin_locks 100k;
  256. lua_shared_dict cache {{memory_cache_size}}m;
  257. lua_shared_dict cassandra 1m;
  258. lua_shared_dict cassandra_prepared 5m;
  259. lua_socket_log_errors off;
  260. {{lua_ssl_trusted_certificate}}
  261.  
  262. init_by_lua_block {
  263. kong = require "kong"
  264. kong.init()
  265. }
  266.  
  267. init_worker_by_lua_block {
  268. kong.init_worker()
  269. }
  270.  
  271. server {
  272. server_name _;
  273. listen {{proxy_listen}};
  274. listen {{proxy_listen_ssl}} ssl;
  275.  
  276. ssl_certificate_by_lua_block {
  277. kong.ssl_certificate()
  278. }
  279.  
  280. ssl_certificate {{ssl_cert}};
  281. ssl_certificate_key {{ssl_key}};
  282. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;# omit SSLv3 because of POODLE (CVE-2014-3566)
  283.  
  284. location / {
  285. default_type 'text/plain';
  286.  
  287. # These properties will be used later by proxy_pass
  288. set $upstream_host nil;
  289. set $upstream_url nil;
  290.  
  291. # Authenticate the user and load the API info
  292. access_by_lua_block {
  293. kong.access()
  294. }
  295.  
  296. # Proxy the request
  297. proxy_set_header X-Real-IP $remote_addr;
  298. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  299. proxy_set_header X-Forwarded-Proto $scheme;
  300. proxy_set_header Host $upstream_host;
  301. proxy_pass $upstream_url;
  302. proxy_pass_header Server;
  303.  
  304. # Add additional response headers
  305. #header_filter_by_lua_block {
  306. # kong.header_filter()
  307. #}
  308.  
  309. # Change the response body
  310. body_filter_by_lua_block {
  311. kong.body_filter()
  312. }
  313.  
  314. # Log the request
  315. log_by_lua_block {
  316. kong.log()
  317. }
  318. }
  319.  
  320. location /robots.txt {
  321. return 200 'User-agent: *\nDisallow: /';
  322. }
  323.  
  324. error_page 500 502 503 504 /50x;
  325.  
  326. location = /50x {
  327. internal;
  328. content_by_lua_block {
  329. require("kong.core.error_handlers")(ngx)
  330. }
  331. }
  332. }
  333.  
  334. server {
  335. listen {{admin_api_listen}};
  336.  
  337. client_max_body_size 10m;
  338. client_body_buffer_size 10m;
  339.  
  340. location / {
  341. default_type application/json;
  342. content_by_lua_block {
  343. ngx.header["Access-Control-Allow-Origin"] = "*"
  344. if ngx.req.get_method() == "OPTIONS" then
  345. ngx.header["Access-Control-Allow-Methods"] = "GET,HEAD,PUT,PATCH,POST,DELETE"
  346. ngx.header["Access-Control-Allow-Headers"] = "Content-Type"
  347. ngx.exit(204)
  348. end
  349. local lapis = require "lapis"
  350. lapis.serve "kong.api.app"
  351. }
  352. }
  353.  
  354. location /nginx_status {
  355. internal;
  356. access_log off;
  357. stub_status;
  358. }
  359.  
  360. location /robots.txt {
  361. return 200 'User-agent: *\nDisallow: /';
  362. }
  363. }
  364. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement