Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add extend points in nginx/kong conf templates #2675

Closed
wants to merge 1 commit into from

Conversation

passos
Copy link

@passos passos commented Jul 6, 2017

Summary

Add three extendsion points in nginx configuration template so that user can put their extend configuration in their own directory instead of update the template file in system library.

Full changelog

  • kong/templates/nginx.lua
  • kong/templates/nginx_kong.lua

Copy link
Contributor

@p0pr0ck5 p0pr0ck5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@passos thanks for the contribution! I wonder if it might make sense to just have this include conf.d/kong_*.conf and such. Currently the appended glob will pick up every file in the directory that matches this prefix; appending .bak or such to a config file is common, but this change would result in those files still being included.

Also, we will definitely want tests for this behavior :)

@p0pr0ck5 p0pr0ck5 added the pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. label Jul 6, 2017
@thibaultcha
Copy link
Member

This is a good idea. However, wouldn't it be friendlier to include kong_*.conf? We do not have a conf.d directory in our Nginx prefix.

@passos FYI, did you get a look at #2355? I like to point this out to what we call "Nginx power users" (people coming to Kong who already knew about Nginx and its internals, and are looking at way to customize their Kong/Nginx instance). The idea is that we know Nginx customization currently is a pain, and we are trying to gather feedback on this idea to better understand if it would improve Kong, or break assumptions about its simplicity and Nginx abstraction.

@p0pr0ck5
Copy link
Contributor

@passos any update?

@p0pr0ck5
Copy link
Contributor

@passos ping

@passos passos force-pushed the conf_extend_point branch from e9cd1ee to 89a2a8d Compare August 26, 2017 12:34
@passos
Copy link
Author

passos commented Aug 26, 2017

@p0pr0ck5 yes, it's good to just include the file with .conf extension. I just updated and commited the change. However this is just a change in configuration template, I have tested it from my local machine but I am not sure how to write unit test for it.

@thibaultcha thibaultcha added pr/status/please review and removed pr/changes requested Changes were requested to this PR by a maintainer. Please address them and ping back once done. labels Jan 20, 2018
@thibaultcha
Copy link
Member

Closing due to lack of updates.

hbagdi added a commit that referenced this pull request Jun 11, 2018
Problem
-------
Kong ships with an NGINX template which is rendered when Kong starts.
There exists no mechanisms to add/update any NGINX directive to the
`nginx.conf` used to run Kong. To change or add any directive, user has
to use a custom NGINX template which has to be synced with Kong for a
release which introduces changes to Kong's template.
Including options in `kong.conf` to configure NGINX directives is not a
good solution since the list will be endless.
This problem can be seen in #3010, #3323 and #3382.

Solution
--------
There needs to be a flexible  way to specify any NGINX directive
via Kong's config file without Kong needing to maintain a list of all
NGINX directives.
While a clean and ideal solution would be #2355, this commit
adopts a simpler as discussed like the one proposed in #2675.

NGINX directives can be specified using config variables with prefixes,
which help determine the block in which to place a directive.
eg:

`nginx_proxy_add_header=Header-Name header-value` will add a `add_header
Header-Name header-value;` directive in the proxy server block of Kong.

`nginx_http_lua_shared_dict=custom_cache 2k` will add a a
`lua_shared_dict custom_cache 2k;` directive to HTTP block of Kong.s
thibaultcha pushed a commit that referenced this pull request Jun 13, 2018
Problem
-------

Kong ships with an NGINX template which is rendered when Kong starts.
There exists no mechanisms to add/update arbitrary NGINX directives to
the `nginx.conf` used to run Kong. To change or add any directive, user
has to use a custom NGINX template which has to be synced with Kong for
a release which introduces changes to Kong's template.  Including
options in `kong.conf` to configure NGINX directives is not a good
solution since the list will be endless. This problem can be seen in
 #3010, #3323, and #3382.

Proposed Solution
-----------------

Proposed in #3382:

There needs to be a flexible  way to specify any NGINX directive via
Kong's config file without Kong needing to maintain a list of all NGINX
directives. While a clean and ideal solution would be #2355, this commit
adopts a simpler approach as described in #3382, and keeps solutions
similar to the one proposed in #2675 possible (by way of injecting an
`include` directive).

NGINX directives can be specified using config variables with prefixes,
which helps determine the block in which to place a directive. E.g.:

* `nginx_proxy_add_header=Header-Name header-value` will add a `add_header
  Header-Name header-value;` directive in the proxy `server` block of
  Kong.

* `nginx_http_lua_shared_dict=custom_cache 2k` will add a
  `lua_shared_dict custom_cache 2k;` directive to `http` block of Kong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants