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
INKPluginInit
initialization function.
Compile your plugin source code, creating a shared library.
Add an entry to your plugin's plugin.config
file.
Add the path to your plugin shared library into the
records.config
file.
Restart Traffic Server.
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.
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 | |
---|---|
Make sure that your plugin is not statically linked with system libraries. |
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