Fortinet white logo
Fortinet white logo

CLI Reference

waf file-compress-rule

waf file-compress-rule

Use this command to compress specific file types in HTTP replies.

Compression can reduce bandwidth, which can reduce delivery time to end users. Modern browsers automatically decompress files before they display web pages.

You can configure most web servers to compress files when they respond to a request. However, if you do not want to configure each of your web servers separately, or if you want to offload compression for performance reasons, you can configure FortiWeb to do the compression.

By default, the maximum pre-compressed file size is 64 KB. FortiWeb transmits files larger than the maximum without compression. You can use the config system advanced command’s max-cache-size setting to adjust the maximum files size. For details, see system advanced.

To apply a compression rule, select it in an inline protection profile. For details, see waf web-protection-profile inline-protection.

To use this command, your administrator account’s access control profile must have either w or rw permission to the wafgrp area. For details, see Permissions.

Syntax

config waf file-compress-rule

edit "<rule_name>"

set compression-type {gzip | brotli}

set compression-level {level1 | level2 | level3 | level4 | level5 | level6 | level7 | level8 | level9 | level10 | level11}

set exclude-url "<exclusion-rule_name>"

next

end

config content-types

edit "<content-types_id>"

set content-type "<content-type_name>"

end

Variable Description Default

"<rule_name>"

Enter the name of a new or existing rule. The maximum length is 63 characters.

To display the list of existing rules, enter:

edit ?

No default.

<entry_index>

Enter the index number of the individual entry in the table. The valid range is 1–9,999,999,999,999,999,999. No default.

compression-type {gzip | brotli}

Set the file compression type. No default.

compression-level {level1 | level2 | level3 | level4 | level5 | level6 | level7 | level8 | level9 | level10 | level11}

Set the compression level for the file to be compressed. No default.

content-type "<content-type_name>"

Enter one of the following content types to compress it:

  • text/plain

  • text/html

  • application/xml(or)text/xml

  • application/soap+xml

  • application/x-javascript

  • text/css

  • application/javascript

  • text/javascript

  • application/json

  • application/rss+xml

To compress multiple file types, add each file type in a separate table entry with its own <entry_index>. See Example.

No default.

exclude-url "<exclusion-rule_name>"

Enter the name of an exclusion to use with the rule, if any. For details, see waf exclude-url. The maximum length is 63 characters. No default.

Example

This example configures a file compression rule that compresses CSS and HTML files, unless they match one of the URLs in the exception named “Compression Exclusion 1.”

config waf file-compress-rule

edit "file-compress-rule_name"

set compression-type gzip

set compression-level level2

set content-types

edit 1

set content-type text/css

next

edit 2

set content-type text/html

next

end

set exclude-url "Compression Exclusion 1"

next

end

Related topics

waf file-compress-rule

waf file-compress-rule

Use this command to compress specific file types in HTTP replies.

Compression can reduce bandwidth, which can reduce delivery time to end users. Modern browsers automatically decompress files before they display web pages.

You can configure most web servers to compress files when they respond to a request. However, if you do not want to configure each of your web servers separately, or if you want to offload compression for performance reasons, you can configure FortiWeb to do the compression.

By default, the maximum pre-compressed file size is 64 KB. FortiWeb transmits files larger than the maximum without compression. You can use the config system advanced command’s max-cache-size setting to adjust the maximum files size. For details, see system advanced.

To apply a compression rule, select it in an inline protection profile. For details, see waf web-protection-profile inline-protection.

To use this command, your administrator account’s access control profile must have either w or rw permission to the wafgrp area. For details, see Permissions.

Syntax

config waf file-compress-rule

edit "<rule_name>"

set compression-type {gzip | brotli}

set compression-level {level1 | level2 | level3 | level4 | level5 | level6 | level7 | level8 | level9 | level10 | level11}

set exclude-url "<exclusion-rule_name>"

next

end

config content-types

edit "<content-types_id>"

set content-type "<content-type_name>"

end

Variable Description Default

"<rule_name>"

Enter the name of a new or existing rule. The maximum length is 63 characters.

To display the list of existing rules, enter:

edit ?

No default.

<entry_index>

Enter the index number of the individual entry in the table. The valid range is 1–9,999,999,999,999,999,999. No default.

compression-type {gzip | brotli}

Set the file compression type. No default.

compression-level {level1 | level2 | level3 | level4 | level5 | level6 | level7 | level8 | level9 | level10 | level11}

Set the compression level for the file to be compressed. No default.

content-type "<content-type_name>"

Enter one of the following content types to compress it:

  • text/plain

  • text/html

  • application/xml(or)text/xml

  • application/soap+xml

  • application/x-javascript

  • text/css

  • application/javascript

  • text/javascript

  • application/json

  • application/rss+xml

To compress multiple file types, add each file type in a separate table entry with its own <entry_index>. See Example.

No default.

exclude-url "<exclusion-rule_name>"

Enter the name of an exclusion to use with the rule, if any. For details, see waf exclude-url. The maximum length is 63 characters. No default.

Example

This example configures a file compression rule that compresses CSS and HTML files, unless they match one of the URLs in the exception named “Compression Exclusion 1.”

config waf file-compress-rule

edit "file-compress-rule_name"

set compression-type gzip

set compression-level level2

set content-types

edit 1

set content-type text/css

next

edit 2

set content-type text/html

next

end

set exclude-url "Compression Exclusion 1"

next

end

Related topics