Home

Traffic Server Software Developers Kit

A Simple Plugin

This section describes how to write, compile, configure, and run a simple Traffic Server plugin. You’ll follow the steps below:

  1. Make sure that your plugin source code contains an INKPluginInit initialization function.

  2. Compile your plugin source code, creating a shared library.

  3. Add an entry to your plugin's plugin.config file.

  4. Add the path to your plugin shared library into the records.config file.

  5. Restart Traffic Server.

Compile Your Plugin

The process for compiling a shared library varies with the platform used, so the Traffic Server API provides makefile templates you can use to create shared libraries on all the supported Traffic Server platforms.

Unix Example

Assuming the sample program is stored in the file hello-world.c, you could use the following commands to building a shared library on Solaris using the GNU C compiler.

gcc -g -Wall -fPIC -o hello-world.o -c hello-world.c
gcc -g -Wall -shared -o hello-world.so hello-world.o

The first command compiles hello-world.c as Position Independent Code (PIC); the second command links the single hello-world.o object file into the hello-world.so shared library.

[Caution] Caution

Make sure that your plugin is not statically linked with system libraries.

HPUX Example

Assuming the sample program is stored in the file hello_world.c, you could use the following commands to build a shared library on HPUX:

cc +z -o hello_world.o -c hello_world.c
ld -b -o hello_world.so hello_world.o