lando / nginx

The Official NGINX Lando Plugin
https://docs.lando.dev/nginx/
GNU General Public License v3.0
6 stars 7 forks source link

Ability to override parts of nginx config rather the whole config #16

Open apotek opened 1 year ago

apotek commented 1 year ago

Background

I posted the following question in Lando slack:

Hi. I need to add some headers to my nginx server (specifically the Allowed* headers). I checked the Lando nginx services docs, and it appears there is no support for a pattern like:

myservice:
  type: nginx
  overrides:
    - nginx_config_var: my_value

And instead the docs indicate: “You may need to override our default nginx config with your own custom server, vhosts or fastcgi_params config.” And there are only options for server, vhosts, params, with no options for additional configs.

  myservice:
    type: nginx
    config:
      server: .lando/config/nginx/my_custom_server.conf

This of course means I would have to duplicate the entire nginx server config.

Is there really no way to override parts of the config? With mysql, for example, I can include a config file to add certain parameters I need rather than override the default config. Is there a better pattern than copy+pasting the shipping nginx server config, modifying it, and then mounting it to the service container?

Considering how common it is to need to modify Allowed headers (especially for development), I must be missing something obvious.

The Request

Be able to add nginx server config without having to override the whole file. Two patterns I have seen elsewhere (Platform SH) for example, and Lando:

Overrides Pattern:

  myservice:
    type: nginx
    config_overrides:
      nginx_var_name: my_value

Include Pattern (like Lando mysql service):

  myservice:
    type: nginx
    config: path/to/my/custom.conf

Where the custom.conf is not the entire server conf file, but just modifications to it, like when apache allows you do include a directory of additional configs etc.