Server Security

Table of Contents

File Access Control

Follow Symbolic Link | Check Symbolic Link | Force Strict Ownership Checking | Required Permission Mask | Restricted Permission Mask | Script Restricted Permission Mask | Script Directory Restricted Permission Mask | 

Per Client Throttling

Static Requests/Second | Dynamic Requests/Second | Outbound Bandwidth | Inbound Bandwidth | Connection Soft Limit | Connection Hard Limit | Block Bad Request | Grace Period (sec) | Banned Period (sec) | 

CGI Settings

CGI Daemon Socket | Max CGI Instances | Minimum UID | Minimum GID | Force GID | CGI Priority | CPU Soft Limit | CPU Hard Limit | Memory Soft Limit | Memory Hard Limit | Process Soft Limit | Process Hard Limit | 

Access Denied Directories

Access Denied Directories | 

Access Control

Allowed List | Denied List | 

Follow Symbolic LinkGo to top
Description: Specifies the server-level default setting of following symbolic links when serving static files.

Choices are Yes, If Owner Match and No.

Yes sets the server to always follow symbolic links. If Owner Match sets the server to follow a symbolic link only if the owner of the link and of the target are same. No means the server will never follow a symbolic link. This setting can be overridden on each individual virtual host.
Syntax: Select from drop down list
Tips: [Performance & security] For best security select No or If Owner Match. For best performance, select Yes.
See Also: Check Symbolic Link.
Check Symbolic LinkGo to top
Description: Specifies whether to check symbolic links against Access Denied Directories when Follow Symbolic Link is turned on. If enabled, the canonical real path of the resource referred by a URL will be checked against the configurable access denied directories. Access will be denied if it falls inside an access denied directory.
Syntax: Select from radio box
Tips: [Performance & security] For best security, enable this option. For best performance, disable it.
See Also: Follow Symbolic Link, Access Denied Directories
Force Strict Ownership CheckingGo to top
Description: Specifies whether to enforce strict file ownership checking. If it is enabled, the web server will check if the owner of the file being served is the same as the owner of the virtual host. If it is different, a 403 Access Denied Error will be returned. This is turned off by default.
Syntax: Select from radio box
Tips: [security] For shared hosting, enable this check for better security.
Required Permission MaskGo to top
Description: Specifies the required permission mask for static files that the web server will serve. For example, if only files that are readable by everyone can be served, set the value to 0004. See man 2 stat for all values.
Syntax: octal numbers
See Also: Restricted Permission Mask.
Restricted Permission MaskGo to top
Description: Specifies the restricted permission mask for static files that the web server will not serve. For example, to prohibit serving files that are executable, set the mask to 0111.

See man 2 stat for all values.
Syntax: octal numbers
See Also: Required Permission Mask.
Script Restricted Permission MaskGo to top
Description: Specifies the restricted permission mask for script files that the web server will not serve. For example, to prohibit serving PHP scripts that are group and world writable, set the mask to 022. Default value is 000.

See man 2 stat for all values.
Syntax: octal numbers
See Also: Script Directory Restricted Permission Mask.
Script Directory Restricted Permission MaskGo to top
Description: Specifies the restricted permission mask of parent directories of script files that the web server will not serve. For example, to prohibit serving PHP scripts in a directory that is group and world writable, set the mask to 022. Default value is 000. This option can be used to prevent serving scripts under a directory of uploaded files.

See man 2 stat for all values.
Syntax: octal numbers
See Also: Script Restricted Permission Mask.
Per Client ThrottlingGo to top
Description: These are connection control settings based on client IP. These settings help to mitigate DoS (Denial of Service) and DDoS (Distributed Denial of Service) attacks.
Static Requests/SecondGo to top
Description: Specifies the maximum number of requests to static content coming from a single IP address that can be processed in a single second regardless of the number of connections established.

When this limit is reached, all future requests are tar-pitted until the next second. Request limits for dynamically generated content are independent of this limit. Per-client request limits can be set at server- or virtual host-level. Virtual host-level settings override server-level settings.
Syntax: Integer number
Tips: [Security] Trusted IPs or sub-networks are not affected.
See Also: Dynamic Requests/Second
Dynamic Requests/SecondGo to top
Description: Specifies the maximum number of requests to dynamically generated content coming from a single IP address that can be processed in each second regardless of the number of connections established. When this limit is reached, all future requests to dynamic content are tar-pitted until the next second.

The request limit for static content is independent of this limit. This per client request limit can be set at server or virtual host level. Virtual host-level settings override server-level settings.
Syntax: Integer number
Tips: [Security] Trusted IPs or sub-networks are not restrained by this limit.
See Also: Static Requests/Second
Outbound BandwidthGo to top
Description: Specifies the maximum allowed outgoing throughput to a single IP address regardless of number of connections established. The real bandwidth may end up being slightly higher than this setting for efficiency reasons. Bandwidth is allocated in 4KB units. Set to 0 to disable throttling. Per-client bandwidth limits (bytes/sec) can be set at server- or virtual-host levels. Virtual host-level settings override server-level settings.
Syntax: Integer number
Tips: [Performance] Set the bandwidth in 8KB units for better performance.
[Security] Trusted IPs or sub-networks are not affected.
See Also: Inbound Bandwidth
Inbound BandwidthGo to top
Description: Specifies the maximum allowed incoming throughput from a single IP address regardless of number of connections established. The real bandwidth may end up being slightly higher than this setting for efficiency reasons. Bandwidth is allocated in 1KB units. Set to 0 to disable throttling. Per-client bandwidth limits (bytes/sec) can be set at server- or virtual-host levels. Virtual host-level settings override server-level settings.
Syntax: Integer number
Tips: [Security] Trusted IPs or sub-networks are not affected.
See Also: Outbound Bandwidth
Connection Soft LimitGo to top
Description: Specifies the soft limit of concurrent connections allowed from one IP. This soft limit can be exceeded temporarily during Grace Period (sec) as long as the number is below the Connection Hard Limit, but Keep-Alive connections will be closed as soon as possible until the number of connections is lower than the limit. If number of connections is still over the limit after the Grace Period (sec), that IP will be blocked for the Banned Period (sec).

For example, if a page contains many small graphs, the browser may try to set up many connections at same time, especially for HTTP/1.0 clients. You would want to allow those connections for a short period.

HTTP/1.1 clients may also set up multiple connections to speed up downloading and SSL requires separate connections from non-SSL connections. Make sure the limit is set properly, as not to adversely affect normal service. The recommended limit is between 5 and 10.
Syntax: Integer number
Tips: [Security] A lower number will enable serving more distinct clients.
[Security] Trusted IPs or sub-networks are not affected.
[Performance] Set to a high value when you are performing benchmark tests with a large number of concurrent client machines.
Connection Hard LimitGo to top
Description: Specifies the maximum number of allowed concurrent connections from a single IP address. This limit is always enforced and a client will never be able to exceed this limit. HTTP/1.0 clients usually try to set up as many connections as they need to download embedded content at the same time. This limit should be set high enough so that HTTP/1.0 clients can still access the site. Use Connection Soft Limit to set the desired connection limit.

The recommended limit is between 20 and 50 depending on the content of your web page and your traffic load.
Syntax: Integer number
Tips: [Security] A lower number will enable serving more distinct clients.
[Security] Trusted IPs or sub-networks are not affected.
[Performance] Set to a high value when you are performing benchmark tests with a large number of concurrent client machines.
Block Bad RequestGo to top
Description: Block IPs that keep sending badly-formated HTTP requests for the Banned Period (sec). Default is Yes. This helps to block botnet attacks that repeatedly sending junk requests.
Syntax: Select from radio box
Grace Period (sec)Go to top
Description: Specifies how long new connections can be accepted after the number of connections established from one IP is over the Connection Soft Limit. Within this period, new connections will be accepted if the total connections is still below the Connection Hard Limit. After this period has elapsed, if the number of connections still higher than the Connection Soft Limit, then the offending IP will be blocked for the Banned Period (sec).
Syntax: Integer number
Tips: [Performance & Security] Set to a proper number big enough for downloading a complete page but low enough to prevent deliberate attacks.
Banned Period (sec)Go to top
Description: Specifies how long new connections will be rejected from an IP if, after the Grace Period (sec) has elapsed, the number of connections is still more than the Connection Soft Limit. If IPs are getting banned repeatedly, we suggest that you increase your banned period to stiffen the penalty for abuse.
Syntax: Integer number
CGI SettingsGo to top
Description: The following settings control CGI processes. Memory and process limits also serve as the default for other external applications if limits have not been set explicitly for those applications.
CGI Daemon SocketGo to top
Description: A unique socket address used to communicate with the CGI daemon. LiteSpeed server uses a standalone CGI daemon to spawn CGI scripts for best performance and security. Default socket is "uds://$SERVER_ROOT/admin/conf/.cgid.sock". If you need to put in another location, specify a Unix domain socket here.
Syntax: UDS://path
Example: UDS://tmp/lshttpd/cgid.sock
Max CGI InstancesGo to top
Description: Specifies the maximum number of concurrent CGI processes the server can start. For each request to a CGI script, the server needs to start a standalone CGI process. On a Unix system, the number of concurrent processes is limited. Excessive concurrent processes will degrade the performance of the whole system and are one way to perform a DoS attack. LiteSpeed server pipelines requests to CGI scripts and limits concurrent CGI processes to ensure the optimal performance and reliability. The hard limit is 2000.
Syntax: Integer number
Tips: [Security & Performance] A higher limit does not necessarily translate to faster performance. In most cases, a lower limit gives better performance and security. A higher limit will only help when I/O latency is excessive during CGI processing.
Minimum UIDGo to top
Description: Specifies the minimum user ID of external applications. Execution of an external script with a user ID lower than the value specified here will be denied. If LiteSpeed web server is started by "root" user, it can run external applications in the "suEXEC" mode like Apache (to change to a user/group ID other than the web server's).
Syntax: Integer number
Tips: [Security] Set it high enough to exclude all system/privileged users.
Minimum GIDGo to top
Description: Specifies the minimum group ID of external applications. Execution of an external with a group ID lower than the value specified here will be denied. If LiteSpeed web server is started by the "root" user, it can run external applications in the "suEXEC" mode found in Apache (to change to a user/group ID other than the web server's).
Syntax: Integer number
Tips: [Security] Set it high enough to exclude all groups used by system users.
Force GIDGo to top
Description: Specifies a group ID to be used for all external applications started in suEXEC mode. When set to non-zero value, all suEXEC external applications (CGI/FastCGI/LSAPI) will use this group ID. This can be used to prevent an external application from accessing files owned by other users.

For example, in a shared hosting environment, LiteSpeed runs as user "www-data", group "www-data". Each docroot is owned by a user account, with a group of "www-data" and permission mode 0750. If Force GID is set to "nogroup" (or any group other than 'www-data'), all suEXEC external applications will run as a particular user but in the group "nogroup". These external application processes will still be able to access files owned by that particular user (because of their user ID), but will not have group permission to access anyone else's files. The server, on the other hand, still can serve files under any user's docroot directory (because of its group ID).
Syntax: Integer number
Tips: [Security] Set it high enough to exclude all groups used by system users.
CGI PriorityGo to top
Description: Specifies priority of the external application process. Value ranges from -20 to 20. A lower number means a higher priority.

A CGI process cannot have a higher priority than the web server. If this priority is set to a lower number than the server's, the server's priority will be used for this value.
Syntax: int
See Also: Server Priority
CPU Soft LimitGo to top
Description: Specifies CPU consumption time limit in seconds for a CGI process. When the process reaches the soft limit, it will be notified by a signal. The operating system's default setting will be used if the value is absent or set to 0.
Syntax: Integer number
CPU Hard LimitGo to top
Description: Specifies maximum CPU consumption time limit in seconds for a CGI process. If the process continues to consume CPU time and reach the hard limit, the process will be force killed. The operating system's default setting will be used if the value is absent or set to 0.
Syntax: Integer number
Memory Soft LimitGo to top
Description: Specifies the memory consumption limit in bytes for an external application process or an external application started by the server.

The main purpose of this limit is to prevent excessive memory usage because of software bugs or intentional attacks, not to impose a limit on normal usage. Make sure to leave enough head room, otherwise your application may fail and 503 error may be returned. It can be set at the server- level or at an individual external application level. The server-level limit will be used if it is not set at the individual application level.

The operating system's default setting will be used if the value is absent at both levels or set to 0.
Syntax: Integer number
Tips: [Attention] Do not over adjust this limit. This may result in 503 errors if your application needs more memory.
Memory Hard LimitGo to top
Description: Much the same as Memory Soft Limit, except the soft limit can be raised up to the hard limit from within a user process. The hard limit can be set at server level or at an individual external application level. The server-level limit will be used if it is not set at an individual application level.

The operating system's default will be used if the value is absent at both levels or set to 0.
Syntax: Integer number
Example: [Attention] Do not over adjust this limit. This may result in 503 errors if your application need more memory.
Process Soft LimitGo to top
Description: Limits the total number of processes that can be created on behalf of a user. All existing processes will be counted against this limit, not just new processes to be started. If the limit is set to 10, and there are more than 10 processes running under one user, then no new process can be started by the web server for that user (through suEXEC).

The main purpose of this limit is to prevent "fork bomb" attacks or excessive usage, not to impose a limit on normal usage. Make sure to leave enough head room. This can be set at the server level or at an individual external application level. The server-level limit will be used if it is not set at an individual application level. The operating system's default setting will be used if this value is 0 or absent at both levels.
Syntax: Integer number
Example: [Attention] All processes run under the same user ID at server level will be counted against this limit. Do not over adjust this limit. Doing so may cause 503 errors if a user needs to create many processes.
Process Hard LimitGo to top
Description: Much the same as Process Soft Limit, except the soft limit can be raised up to the hard limit from within a user process. The hard limit can be set at the server level or at an individual external application level. The server-level limit will be used if it is not set at an individual application level. The operating system's default value will be used if the value is absent at both levels or set to 0.
Syntax: Integer number
Access Denied DirectoriesGo to top
Description: Specifies directories that should be blocked from access. Add directories that contain sensitive data to this list to prevent accidentally exposing sensitive files to clients. Append a "*" to the path to include all sub-directories. If both Follow Symbolic Link and Check Symbolic Link are enabled, symbolic links will be checked against the denied directories.
Syntax: Comma-delimited list of directories
Tips: [Security] Of critical importance: This setting only prevents serving static files from these directories. This does not prevent exposure by external scripts such as PHP/Ruby/CGI.
Access ControlGo to top
Description: Specifies what sub networks and/or IP addresses can access the server. This is a server-level setting that affects all virtual hosts. You can also set up access control unique to each virtual host. Virtual host settings will NOT override the server settings.

Whether to block/allow an IP is determined by the combination of the allowed list and denied list. If you want to block only certain IPs or sub-networks, put * or ALL in Allowed List and list the blocked IPs or sub-networks in Denied List. If you want to only allow certain IPs or sub-networks, put * or ALL in Denied List and list the allowed IPs or sub-networks in Allowed List. The setting of the smallest scope that fits for an IP will be used to determine whether to block or allow that IP.

Trusted IPs or sub-networks must be specified in Allowed List by adding a trailing "T". Trusted IPs or sub-networks are not affected by connection/throttling limits. Only server-level access control can set up trusted IPs/sub-networks.
Tips: [Security] Use this for general restrictions that apply to all virtual hosts.
Allowed ListGo to top
Description: Specifies the list of IPs or sub-networks allowed. * or ALL are accepted.
Syntax: Comma delimited list of IP addresses or sub-networks. A trailing "T" can be used to indicate a trusted IP or sub-network, such as 192.168.1.*T.
Example: Sub-networks: 192.168.1.0/255.255.255.0, 192.168.1.0/24, 192.168.1 or 192.168.1.*.
IPv6 addresses: ::1 or [::1]
IPv6 subnets: 3ffe:302:11:2:20f:1fff:fe29:717c/64 or [3ffe:302:11:2:20f:1fff:fe29:717c]/64.
Tips: [Security] Trusted IPs or sub-networks set at the server-level access control will be excluded from connection/throttling limits.
Denied ListGo to top
Description: Specifies the list of IPs or sub-networks disallowed.
Syntax: Comma delimited list of IP addresses or sub-networks. * or ALL are accepted.
Example: Sub-networks: 192.168.1.0/255.255.255.0, 192.168.1.0/24, 192.168.1 or 192.168.1.*.
IPv6 addresses: ::1 or [::1]
IPv6 subnets: 3ffe:302:11:2:20f:1fff:fe29:717c/64 or [3ffe:302:11:2:20f:1fff:fe29:717c]/64.

STAY CONNECTED