A Simple Plugin¶
This section describes how to write, compile, configure, and run a simple Traffic Server plugin. You’ll follow the steps below:
Make sure that your plugin source code contains an
Compile your plugin source code, creating a shared library.
Add an entry to
Add the path to your plugin shared library into
Restart Traffic Server.
Update the plugin configuration file¶
Your next step is to tell Traffic Server about the plugin by adding the
following line to
plugin.config file. Since our simple plugin
does not require any arguments, the following
# a simple plugin.config for hello_world
Traffic Server can accommodate multiple plugins. If several plugin
functions are triggered by the same event, then Traffic Server invokes
each plugin’s function in the order each was defined in
Specify the Plugin’s Location¶
All plugins must be located in the directory specified by the
proxy.config.plugin.plugin_dir, which is
located in the
records.yaml file. The directory can be specified
as an absolute or relative path.
If a relative path is used, then the starting directory will be the
Traffic Server installation directory as specified in
etc/traffic_server. The default value is
but this can vary based on how the software was configured and built. It
is common to use the default directory. Be sure to place the shared
hello_world.so inside the directory you’ve configured.
Restart Traffic Server¶
The last step is to start/restart Traffic Server. Shown below is the
output displayed after you’ve created and loaded your
# ls libexec/trafficserver
[Mar 27 19:06:31.669] NOTE: updated diags config
[Mar 27 19:06:31.680] NOTE: loading plugin 'libexec/trafficserver/hello_world.so'
[Mar 27 19:06:32.046] NOTE: cache disabled (initializing)
[Mar 27 19:06:32.053] NOTE: cache enabled
[Mar 27 19:06:32.526] NOTE: Traffic Server running