Configuration overview
You can type or paste the script content into the configuration page.
Before you begin:
- Create a script.
- You must have Read-Write permission for Server Policy settings.
After you have created a script configuration object, you can reference it in the virtual server configuration.
To configure a script:
- Go to Application Delivery > Scripting.
- Click Create New to display the configuration editor.
- Complete the configuration as shown.
Settings Guidelines Name
Enter a unique name. No spaces or special characters.
After you initially save the configuration, you cannot edit the name.
Input
Type or paste the script.
- Click OK to Save the configuration.
- You can also click Import to import a script file. It should be a ".txt" file.
- When creating a server policy, in the Scripting section, enable Scripting, then select the scripts you want to run for this server policy.
Script Events
There are predefined scripts which specify the following events. When the events occur, it will trigger the system to take the actions defined in the script.
Type |
Event |
Description |
---|---|---|
RULE |
RULE_INIT |
When the server policy enables or reloads. |
RULE_EXIT |
When the server policy disables or reloads. | |
HTTP |
HTTP_REQUEST |
When the server policy has received the complete HTTP request header. |
HTTP_RESPONSE |
When the server policy has received the complete HTTP response header. | |
TCP |
CLIENT_ACCEPTED |
When the server policy has accepted a client connection. |
CLIENT_CLOSED |
When the server policy has closed a client connection. | |
SERVER_CONNECTED |
When the server policy has connected to a server. | |
SERVER_CLOSED |
When the server policy has closed a server connection. |
Event priority
FortiWeb supports multiple scripts in one server policy. When a server policy with scripts is enabled, the system will load scripts one by one. If there are multiple same events defined in the scripts, the event running order is same as the loading order.
If you want to run a certain event first regardless of the script order, you can define its priority to prioritize its sequence. The default priority of events is 500. Lower value has higher priority.
For example:
when HTTP_REQUEST priority 499 {
...
}
Lua package compatibility
FortiWeb uses the lua version 5.4.
Package name |
Compatible details |
---|---|
global |
Supported, but: • Disable dofile() • Disable loadfile() • Modify print() to FortiWeb version, printing to debug log with level 1. ( |
package |
Disabled |
coroutine | Disabled |
table | Supported |
io | Disabled |
os | Disabled |
string | Supported |
math | Supported |
utf8 |
Supported |