C Setting CGIDScriptTimeout When Using mod_cgid
Oracle HTTP Server includes mod_cgi
and mod_cgid
modules provided by Apache to run the CGI scripts.
When configuring Apache to handle CGI scripts, you must choose between
mod_cgi
and mod_cgid
based on the
Multi-Processing Module (MPM) that you are using.
For single-threaded MPMs like prefork, use mod_cgi
because it is lightweight and runs efficiently within the server process. For
multi-threaded MPMs like worker or event, use mod_cgid
which
offloads CGI execution to a separate daemon that avoids threading issues. The
mod_cgid
module has optimizations to improve the system
performance in a multi-threaded environment as compared to the
mod_cgi
module. See Apache Module mod_cgid.
To check your MPM, run apachectl -V | grep MPM
, and
load the appropriate module (mod_cgi
or mod_cgid
)
in your Apache configuration followed by a server restart to apply changes.
For windows, mod_cgi
module is needed as shown in the
following example:
<IfModule cgi_module>
#
# CGIDScriptTimeout: Limits the waiting time for output from the CGI program
# Replace 20 with the actual timeout value to be set in seconds
#
CGIDScriptTimeout 20
</IfModule>
By default, the mod_cgid
module is loaded when using a multi-threaded MPM on Unix. To verify the configuration:
- Open the
httpd.conf
file using the Advanced Server Configuration page in the Fusion Middleware Control or a text editor. - In the
LoadModule
section, ifmod_cgid
is not configured already, add the following lines to load themod_cgid
module:<IfDefine OHS_MPM_EVENT> LoadModule cgid_module "${PRODUCT_HOME}/modules/mod_cgid.so" </IfDefine> <IfDefine OHS_MPM_WORKER> LoadModule cgid_module "${PRODUCT_HOME}/modules/mod_cgid.so" </IfDefine>
The mod_cgid
module supports the CGIDScriptTimeout
directive that can be used to limit the length of time to wait for more output from the CGI program.
- CGIDScriptTimeout Directive
This directive limits the length of time to wait for more output from the CGI program.
CGIDScriptTimeout Directive
This directive limits the length of time to wait for more output from the CGI program.
If the time exceeds, the request and the CGI get terminated. It can be used to limit resource exhaustion due to the CGI scripts that stop communicating with the server and can protect against both unintentional errors and malicious actions (for example, DoS attacks).
By default, mod_cgid
uses the Timeout Directive to limit the length of time to wait for CGI output. This timeout can be overridden with the CGIDScriptTimeout
directive. The default value of CGIDScriptTimeout
is the Timeout directive, when it is not set or set to 0
. To configure CGIDScriptTimeout
:
- Open the
httpd.conf
file using the Advanced Server Configuration page in the Fusion Middleware Control or a text editor. - Add the following lines for configuring the
CGIDScriptTimeout
directive:<IfModule cgid_module> # # CGIDScriptTimeout: Limits the waiting time for output from the CGI program # Replace 20 with the actual timeout value to be set in seconds # CGIDScriptTimeout 20 </IfModule>
Note:
Testing should be performed with your application to ensure the best results. The timeout value should be set based on the time required by your CGI program to send output back to OHS. The above configuration instructs OHS to wait for 20 seconds for output from the CGI program.Parent topic: Setting CGIDScriptTimeout When Using mod_cgid