Feature #13054
closedPackage plugin hook for web server configuration stanzas
100%
Description
Packages may potentially need to add server and location blocks to the web server configuration for various reasons. We should add plugin hooks that let packages define their own stanzas in at least two places:
location
definitions inside the mainserver
configuration stanzaserver
definitions later in the file, after the web server and redirect blocks.
Updated by Jim Pingle almost 2 years ago
- Target version set to 2.7.0
- Plus Target Version set to 23.05
Updated by Jim Pingle over 1 year ago
Implementation is as described in the issue description. The plugin can be defined in a package as in the following example:
First, declare the plugin by name (plugin_nginx
) in the package XML:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd">
<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?>
<packagegui>
<copyright>
</copyright>
<name>testnginx</name>
<title>testnginx</title>
<include_file>/usr/local/pkg/testnginx.inc</include_file>
<plugins>
<item>
<type>plugin_nginx</type>
</item>
</plugins>
</packagegui>
And then in the package code, implement a function called <packagename>_plugin_nginx
:
<?php
function testnginx_plugin_nginx($pluginparams) {
global $config;
/* Caller did not properly define data, exit early */
if (!is_array($pluginparams) ||
empty($pluginparams) ||
empty($pluginparams['section'])) {
return "";
}
$result = "";
switch ($pluginparams['section']) {
case 'location':
$result = " # This content is placed after the location stanzas of the main GUI server.";
break;
case 'server':
$result = " # This content is placed after the server stanza of the GUI server(s)";
break;
default:
$result = "# Nothing to do here, no section given.";
}
return $result;
}
The 'section'
parameter passed in from the caller will let the function know if it's being called for a location block in the main GUI server or for a server block that is separate. Be sure to indent the content appropriately (two tab levels for locations, one tab level for servers).
This function does not currently support captive portal but could be extended to do so in the future.
Updated by Jim Pingle over 1 year ago
- Status changed from In Progress to Feedback
- % Done changed from 0 to 100
Applied in changeset 3019cad09231b105f955d161a6e24d98d3623b71.