nginx: Allow multiple contexts for `custom_config`

Virtual hosts have a custom_config, which allows you to place custom configs. For nginx, this custom config is always placed in the server context. But sometimes, users need to place custom configs in other places, most notably in the location ~ \.php block that we add statically.

A current case is as follows. Sometimes, directives need to be added to a specific PHP path, for example in the case of a Satis webhook:

location = /webhook.php {
   auth_basic "off";
   allow all;
}

Because nginx does not merge but overwrites locations, this causes the directives in location ~ \.php to no longer have any effect on /webhook.php.

To work around that, the customer must duplicate the directives in location ~ \.php himself, but:

  • These are 'implementation details'. I.e. they can change anytime, and are really our (internal) business.

  • The socket path to the FPM pool must be hardcoded, which goes sideways when the virtual host's FPM pool is changed.

The most elegant solution: turn custom_config from a text field of which the content is always placed in the server context, into an array with multiple possible values (such as location_php or generic).

Please authenticate to join the conversation.

Upvoters
Status

In Review

Board

Core

Date

2 months ago

Author

William Edwards

Subscribe to post

Get notified by email when there are changes.