Configuring decompression rules
If the HTTP/HTTPS request body is compressed, FortiADC cannot pass it to the other functional modules which perform inspection or modification.
To allow FortiADC to pass compressed HTTP/HTTPS client requests to other modules for inspection or modification before forwarding it to the back-end server, you must create a FortiADC decompression policy.
You can configure FortiADC to temporarily decompress the body of a request based on its file type, which can be specified by the HTTP/HTTPS Content‑Type: header. The appliance can then inspect or modify the traffic. If no inspection or modification is needed, it will allow the compressed version of the request to pass to the back-end server.
FortiADC supports HTTP/HTTPS request decompression in either gzip or deflate format. Upon receiving a compressed HTTP/HTTPS request body, FortiADC first extracts the HTTP/HTTPS request body to a temporary buffer and then sends the buffer to the other modules.
Note that, for the current release, decompression only works for Web Application Firewall (WAF) and Scripting functions.
FortiADC supports decompression of the following content-type files:
- application/javascript
- application/soap+xml
- application/x-javascript
- application/xml
- text/css
- text/html
- text/javascript
- text/plain
- text/xml
- custom
Before you begin:
- You must have a good understanding of HTTP decompression and knowledge of the content types served from the backend real servers.
- You must have Read-Write permission for Load Balance settings.
Decompression is not enabled by default. After you have configured a decompression rule, you can select it in the profile configuration. To enable decompression, select the profile when you configure the virtual server.
To configure a decompression rule:
- Click Server Load Balance > Application Resources.
- Click the Decompression tab.
- Click Create New to display the configuration editor.
- Complete the configuration as described in Decompression configuration.
- Save the configuration.
Settings | Guidelines |
---|---|
Name |
Specify a unique name for the decompression rule. Configuration name. Valid characters are Note: After you initially save the configuration, you cannot edit the name. |
URI List Type |
|
URI List |
Click Add and specify URIs to build the list. |
Content Types |
Click Add and select from the following content types to build the list:
Note: The "custom" option allows you to specify almost any content/media type, including image files in .JPG, .PNG, and .BMP formats. The default is */*, which means any content/media type. |
You can use the CLI to configure decompression rules: config load-balance decompression edit <name> set cpu-limit {enable | disable} set max-cpu-usage [1-100] set uri-list-type {include | exclude} config uri_list edit <ID> set uri <refex_pattern> next end config content-types edit <ID> set content-type <types> { application/javascript application/soap+xml application/x-javascript application/xml custom <plain-string> text/css text/html text/javascript text/plain text/xml } next end |
|
You can use the CLI to select a decompression rule in a server load balance profile (HTTP): config load-balance profile edit <name> ... set decompression <decompression name> ... next end |
Using decompression with script data body manipulation
Script data body manipulation can work in tandem with compression or decompression rules in a rather transparent way. When a decompression rule is configured and used with scripting, FortiADC will decompress HTTP data first, then apply script data body manipulation, and then re-compress the data before sending it to clients.
So, if HTTP data is compressed before being sent out from the real server, you must create a decompression rule if you want to access the original data and use it in a script. This can be done either via the GUI or the Console. The following paragraphs show you the basic steps for configuring decompression rules to work with script data body manipulation.
From the GUI
Step 1: Creating a decompression rule
- Click Server Load Balance > Application Resources > Decompression.
- Click Create New to open the Decompression configuration dialog.
- For Name, specify a unique name for the decompression rule.
- For URI Rule Type, select Include or Exclude.
- Click Save. The dialog closes and the decompression rule appears in the Decompression table.
- Double-click the decompression rule (or click the corresponding Edit button) to open it.
- In the URI Rule section, make the desired configuration. (Optional)
- In the Content Types sections, make the desired configuration. (Optional)
- Click Save.
- Repeat the above steps to create as many decompression rules as needed.
Step 2: Configuring a load balance profile
- Click Server Load Balance > Application Resources > Application Profile.
- Click Create New to open the Application Profile configuration dialog.
- For Type, click the down arrow and select HTTP or HTTPS from the list menu.
- For Decompression, click the down arrow and select a decompression rule from the list menu.
- Complete all the other fields required for load-balancing profile configuration.
- Click Save.
Step 3: Enabling scripting in virtual server configuration
- Click Server Load Balance > Virtual Server > Virtual Server.
- Click Add > Advanced Mode.
- For Type (under the Basic section), be sure to select Layer 7.
- For Profile (under the General section), be sure to select an HTTP or HTTPS profile associated with the decompression rules that you have configured.
- For Scripting, be sure to turn it on (enable it), and then select the desired script or scripts.
- Complete all the other fields required for virtual server configuration.
- Click Save.
From the Console
Use the following example commands as a reference when configuring decompression and script data body manipulation from the Console.
Step 1: Creating a decompression rule
config load-balance decompression
edit "decompress"
set uri-list-type include
config uri_list
edit 1
set uri /
next
end
config content_types
edit 1
set content-type text/html
next
end
next
end
Step 2: Configuring a load balance profile
config load-balance profile
edit "http"
set type http
set decompression decompress
next
end
Step 3: Enabling scripting in virtual server configuration
config load-balance virtual-server
edit "vs"
set load-balance-profile http
set scripting-flag enable
set scripting-list data
next
end