Special environment variables in LiteSpeed Rewrite Rules
The following are the Special Environment Variables that can be used in rewrite rules to control features:
dontlog
Once set, skips access logging, the value does not matter, for example:
RewriteRule \.gif - [E=dontlog:1]
nokeepalive
Closes the client's connection after finishing this request, the value does not matter, for example:
RewriteRule .* - [E=nokeepalive:1]
no-gzip
Do not use gzip compression for this request, must be set to a non-zero value, for example:
RewriteRule \.css - [E=no-gzip:1]
no-gzip:0 has no effect.
Proxy-Host
Modify proxy request “Host” header value, for example: A web site's domain name is “www.example.com”, it sends a proxy request to the backend, the backend is defined as a web server with name “node1”, it requires the domain name to be “www.example.com”, the rewrite rule should be
RewriteRule ^(.*)$ http://node1/$1 [P,E=Proxy-Host:www.example.com]
cache-ctrl/cache-control
Modify LSWS page cache policy enable cache
Rewriterule ^/special_cachable_url$ - [E=Cache-ctrl:max-ages=30] Rewriterule ^/non-cacheable-url$ - [E=Cache-control:no-cache]
No abort
This flag prevents external app processes from being killed by LSWS as a runaway process while it is in the middle of processing.
RewriteRule ^script_url$ - [E=noabort:1]
wait-req-full-body
When LSWS processes a request, it usually passes the request to the backend (PHP) without waiting for the full request body to complete. Usually, this is not a problem, but it can be an issue if the script needs the whole request body to work properly. As of v5.4.8 build 4, the wait-req-full-body
environment variable allows you to control this. It can be set via SetEnv, SetEnvIf or a rewrite rule.
RewriteRule ^(.*)$ - [E=wait-req-full-body:1]
or
SetEnv wait-req-full-body 1