Server Security

Table of Contents

File Access

跟随符号链接 | 检查符号链接 | 强制严格属主检查 | Required Permission Mask | 限制权限掩码 | 脚本限制权限掩码 | 脚本目录限制权限掩码

Per Client Throttling

静态请求/秒 | Dynamic Requests/Second | 出口带宽 | 入口带宽 | 连接软限制 | 连接硬限制 | 封锁坏请求 | 宽限期(秒) | 禁止期(秒)

CGI Settings

CGI守护进程套接字 | 最大CGI实例数量 | 最小的UID | 最小的GID | 强制GID | umask | CGI优先级 | CPU软限制 | CPU硬限制 | 内存软限制 | 内存硬限制 | 进程软限制 | 进程硬限制 | cgroups

reCAPTCHA Protection

Enable reCAPTCHA | Site Key | Secret Key | reCAPTCHA Type | Max Tries | Allowed Robot Hits | Bot White List | Connection Limit | SSL Connection Limit

Bubblewrap Container

Bubblewrap Container | Bubblewrap Command

Access Denied Directories

拒绝访问的目录

登入限制

允许列表 | 拒绝列表

Description

指定服务静态文件时跟踪符号链接的服务器级别默认设置。

选项有YesIf Owner MatchNo

Yes设置服务器始终跟踪符号链接。 If Owner Match设置服务器只有在链接和目标属主一致时才跟踪符号链接。 No表示服务器永远不会跟踪符号链接。 该设置可以在虚拟主机配置中覆盖,但不能通过.htaccess文件覆盖。

Syntax

选项

Tips

[性能和安全建议] 要获得最佳安全性,选择{VAL}No或If Owner Match。 要获得最佳性能,选择{VAL}Yes。

See Also

检查符号链接.

Description

指定在启用了跟随符号链接时,是否检查符号链接在不在拒绝访问的目录中。 如果启用检查,将检查网址对应的真正的资源路径是否在配置的禁止访问目录中。 如果在禁止访问目录中,访问将被禁止。

Syntax

布尔值

Tips

[性能和安全] 要获得最佳的安全性,启用该选项。要获得最佳性能,禁用该选项。

See Also

跟随符号链接, 拒绝访问的目录

强制严格属主检查

Description

指定是否执行严格的文件所有权检查。 如果启用,Web服务器将检查正在服务的文件的所有者与虚拟主机的所有者是否相同。 如果不同,将返回403拒绝访问错误。 该功能默认是关闭的。

Syntax

布尔值

Tips

[安全建议] 对于共享主机,启用此检查以得到更好的安全性。

Required Permission Mask

Description

为静态文件指定必需的权限掩码。 例如,如果只允许所有人都可读的文件可以被输出,将该值设置为0004。 用man 2 stat命令了解所有可选值。

Syntax

八进制数

See Also

限制权限掩码.

限制权限掩码

Description

为不能输出的静态文件指定限制权限掩码。 例如,要禁止服务可执行文件,将掩码设置为0111

man 2 stat命令了解所有可选值。

Syntax

八进制数

See Also

Required Permission Mask.

脚本限制权限掩码

Description

为不能服务的脚本文件指定限制权限掩码。 例如,要禁止服务属组可写和全局可写的PHP脚本, 设置掩码为022。默认值是000

man 2 stat命令了解所有可选值。

Syntax

八进制数

See Also

脚本目录限制权限掩码.

脚本目录限制权限掩码

Description

为不能服务的脚本文件父目录指定限制权限掩码。 例如,要禁止服务属组可写和全局可写的文件夹内的PHP脚本, 设置掩码为022。默认值是000。 此选项可用于防止执行文件上传目录内的脚本。

man 2 stat命令了解所有可选值。

Syntax

八进制数

See Also

脚本限制权限掩码.

Per Client Throttling

Description

These are connection control settings are based on client IP. These settings help to mitigate DoS (Denial of Service) and DDoS (Distributed Denial of Service) attacks.

静态请求/秒

Description

指定每秒可处理的来自单个IP的静态内容请求数量(无论与该IP之间建立了多少个连接)。

当达到此限制时,所有后来的请求将被延滞到下一秒。 对于动态内容请求的限制与本限制无关。 每个客户端的请求限制可以在服务器或虚拟主机级别设置。 虚拟主机级别的设置将覆盖服务器级别的设置。

Syntax

无符号整数

Tips

[安全] 受信任的IP或子网不受影响。

See Also

Dynamic Requests/Second

Dynamic Requests/Second

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

无符号整数

Tips

Trusted IPs or sub-networks are not restrained by this limit.

See Also

静态请求/秒

出口带宽

Description

指定对单个IP地址允许的最大传出吞吐量(无论与该IP之间建立了多少个连接)。 为提高效率,真正的带宽可能最终会略高于设定值。 带宽按4KB为单位分配。设定值为0可禁用限制。 每个客户端的带宽限制(字节/秒)可以在服务器或虚拟主机级别设置。 虚拟主机级别的设置将覆盖服务器级别的设置。

Syntax

无符号整数

Tips

[性能建议] 按8KB单位设置带宽可获得更好的性能。
[安全建议] 受信任的IP或子网不受影响。

See Also

入口带宽

入口带宽

Description

指定对单个IP地址允许的最大传入吞吐量(无论与该IP之间建立了多少个连接)。 为提高效率,真正的带宽可能最终会略高于设定值。 带宽是按1KB单位分配。设定值为0可禁用限制。 每个客户端的带宽限制(字节/秒)可以在服务器或虚拟主机级别设置。 虚拟主机级别的设置将覆盖服务器级别的设置。

Syntax

无符号整数

Tips

[安全] 受信任的IP或子网不受影响。

See Also

出口带宽

连接软限制

Description

指定来自单个IP的并发连接的软限制。 并发连接数低于连接硬限制时,此软限制可以在宽限期(秒)期间临时超过, 但Keep-Alive连接将被尽快断开,直到连接数低于软限制。 如果宽限期(秒)之后,连接数仍然超过软限制,相应的IP将被封锁 禁止期(秒)所设置的时长。

例如,如果页面包含许多小图像,浏览器可能会尝试同时建立许多连接,尤其是HTTP/1.0客户端。你应当在短时间内允许这些连接。

HTTP/1.1客户端还可能建立多个连接,以加快下载,另外SSL需要为非SSL连接建立单独的连接。确保限制设置正确, 以免影响正常服务。建议限制在510之间。

Syntax

无符号整数

Tips

[安全建议] 一个较低的数字将使得服务器可以服务更多独立的客户。
[安全建议] 受信任的IP或子网不受影响。
[性能建议] 使用大量并发客户端进行性能评测时,请设置一个较高的值。

连接硬限制

Description

指定来自单个IP的并发连接的硬限制。 此限制是永远执行的,客户端将永远无法超过这个限制。 HTTP/1.0客户端通常会尝试建立尽可能多的连接,因为它们需要同时下载嵌入的内容。此限制应设置得足够高,以使HTTP/1.0客户端仍然可以访问相应的网站。 使用连接软限制设置期望的连接限制。

建议根据你的网页内容和流量负载,限制在2050之间。

Syntax

无符号整数

Tips

[安全] 一个较低的数字将使得服务器可以服务更多独立的客户。
[安全] 受信任的IP或子网不受影响。
[性能] 使用大量并发客户端进行基准测试时,设置一个较高的值。

封锁坏请求

Description

封锁持续发送坏HTTP请求的IP禁止期(秒)所设置的时长。默认为{VAL}Yes。 这有助于封锁反复发送垃圾请求的僵尸网络攻击。

Syntax

布尔值

宽限期(秒)

Description

指定来自一个IP的连接数超过连接软限制之后, 多长时间之内可以继续接受新连接。在此期间,如果总连接数仍然 低于连接硬限制,将继续接受新连接。之后,如果连接数 仍然高于连接软限制,相应的IP将被封锁禁止期(秒)里设置的时长。

Syntax

无符号整数

Tips

[性能与安全建议] 设置为足够大的数量,以便下载完整网页, 但也要足够低以防范蓄意攻击。

禁止期(秒)

Description

指定在宽限期(秒)之后,如果连接数仍然高于 连接软限制,来自该IP的新连接将被拒绝多长时间。如果IP 经常被屏蔽,我们建议您延长禁止期以更强硬地惩罚滥用。

Syntax

无符号整数

CGI Settings

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守护进程套接字

Description

用于与CGI守护进程沟通的唯一套接字地址。为了 最佳性能和安全性,LiteSpeed服务器使用一个独立的CGI 守护进程来产生CGI脚本的子进程。 默认套接字是“uds://$SERVER_ROOT/admin/conf/.cgid.sock”。 如果你需要放置在另一个位置,在这里指定一​​个Unix域套接字。

Syntax

UDS://路径

Example

例如UDS://tmp/lshttpd/cgid.sock

最大CGI实例数量

Description

指定服务器可以启动的CGI进程最大并发数量。 对于每个对CGI脚本的请求,服务器需要启动一个独立的CGI进程。 在Unix系统中,并发进程的数量是有限的。过多的并发进程会降 低整个系统的性能,也是一种进行拒绝服务攻击的方法。 LiteSpeed服务器将对CGI脚本的请求放入管道队列,限制并发 CGI进程数量,以确保最优性能和可靠性。 硬限制为2000

Syntax

无符号整数

Tips

[安全和性能建议] 更高的数量并不一定转化为更快的性能。 在大多数情况下,更低的数量提供更好的性能和安全性。更高的数量 只在CGI处理过程中读写延迟过高时有帮助。

最小的UID

Description

指定外部应用程序的最小用户ID。 如果用户ID比这里指定的值更低。其外部脚本的执行将被拒绝。 如果的LiteSpeed Web服务器由“Root”用户启动,它可以在“suEXEC” 模式运行外部应用程序,类似Apache(可以切换到与Web服务器不同的用户/组ID)。

Syntax

无符号整数

Tips

[安全] 设置足够高的值以排除所有系统/特权用户。

最小的GID

Description

指定外部应用程序的最小组ID。 如果组ID比这里指定的值更小,其外部脚本的执行将被拒绝。 如果的LiteSpeed Web服务器是由“Root”用户启动,它可以在“suEXEC” 模式运行外部应用程序,类似Apache(可以切换到与Web服务器不同的用户/组ID)。

Syntax

无符号整数

Tips

[安全] 设置足够高的值以排除所有系统用户所属的组。

强制GID

Description

指定一组ID,以用于所有在suEXEC模式下启动的外部应用程序。 当设置为非零值时,所有suEXEC的外部应用程序(CGI、FastCGI、 LSAPI)都将使用该组ID。这可以用来防止外部应用程序访问其他用 户拥有的文件。

例如,在共享主机环境,LiteSpeed以“www-data”用户、“www-data”组 身份运行。每个文件根目录是由用户帐户所有,属组为“www-data”,权限 为0750。如果强制GID被设置为“nogroup”(或“www-data”之外的任何一 个组),所有suEXEC外部应用程序都将以特定用户身份运行,但属组为 “nogroup”。这些外部应用程序的进程依然能够访问属于相应用户的文件( 因为他们的用户ID),但没有组权限访问其他人的文件。另一方面,服务器 仍然可以服务在任何用户文件根目录下的文件(因为它的组ID)。

Syntax

无符号整数

Tips

[安全建议] 设置足够高的值以排除所有系统用户所在的组。

umask

Description

设置CGI进程默认的umask。 通过 man 2 umask命令了解详细信息。这也可作为外部应用程序umask的默认值。

Syntax

数值有效范围为[000] - [777]。

See Also

ExtApp umask

CGI优先级

Description

指定外部应用程序进程的优先级。数值范围从-2020。数值越小,优先级越高。

CGI进程不能拥有比Web服务器更高的优先级。如果这个优先级数值被设置为低于 服务器的优先级数值,则将使用服务器优先级作为替代。

Syntax

整数

See Also

Server 优先级

CPU软限制

Description

以秒为单位,指定CGI进程的CPU占用时间限制。当进程达到 软限制时,将收到通知信号。如果没有设置该限制,或者限制设为0, 将使用操作系统的默认设置。

Syntax

无符号整数

CPU硬限制

Description

以秒为单位,指定CGI进程的CPU占用时间限制。 如果进程持续占用CPU时间,达到硬限制,则进程将被强制杀死。如果没有设置该限制,或者限制设为0, 操作系统的默认设置将被使用。

Syntax

无符号整数

内存软限制

Description

以字节为单位指定服务器启动的外部应用进程或程序的内存占用限制。

此限制的目的主要是为了防范软件缺陷或蓄意攻击造成的过度内存使用, 而不是限制正常使用。确保留有足够的内存,否则您的应用程序可能故障并 返回503错误。限制可以在服务器级别或独立的外部应用程序级别设置。如 果未在独立的外部应用程序级别设定限制,将使用服务器级别的限制。

如果在两个级别都没有设置该限制,或者限制值设为0,将使用操 作系统的默认设置。

Syntax

无符号整数

Tips

[注意] 不要过度调整这个限制。如果您的应用程序需要更多的内存, 这可能会导致503错误。

内存硬限制

Description

内存软限制非常相同,但是在一个用户进程中,软限制 可以被放宽到硬限制的数值。硬限制可以在服务器级别或独立的外部应用程序级别设 置。如果未在独立的外部应用程序级别设定限制,将使用服务器级别的限制。

如果在两个级别都没有设置该限制,或者限制值设为0,将使用操 作系统的默认设置。

Syntax

无符号整数

Tips

Do not over adjust this limit. This may result in 503 errors if your application need more memory.

进程软限制

Description

限制一个用户可以创建的进程总数。所有存在的进程都将被统计在内, 而不是只包括新启动的进程。如果限制被设置为10,并且一个用户下 有超过10个进程在运行,那么网站服务器将不会再为该用户(通过 suEXEC) 启动新进程。

此限制的主要目的是为了防范“fork炸弹”攻击或过量使用,而不是限制正常使用 (如果该限制被设置的过低,它将被服务器忽略)。确保留有足够空余。 本项目可以在服务器级别或独立的外部应用程序级别设置。如果未在独立的外部应用程 序级别设定限制,将使用服务器级别的限制。如果在两个级别都没有设置该限制, 或者限制值设为0,将使用操作系统的默认设置。

Syntax

无符号整数

Tips

PHP scripts can call for forking processes. The main purpose of this limit is as a last line of defense to prevent fork bombs and other attacks caused by PHP processes creating other processes.

Setting this setting too low can severely hurt functionality. The setting will thus be ignored below certain levels.

When Run On Start Up is set to "Yes (Daemon mode)", the actual process limit will be higher than this setting to make sure parent processes are not limited.

进程硬限制

Description

进程软限制非常相同,但是,在用户进程中软限制 可以被放宽到硬限制的数值。硬限制可以在服务器级别或独立的外部应用程序级别设 置。如果未在独立的外部应用程序级别设定限制,将使用服务器级别的限制。 如果在两个级别都没有设置该限制,或者限制值设为0,将使用操 作系统的默认设置。

Syntax

无符号整数

cgroups

Description

Apply cgroup settings to this CGI process if supported by the current OS. At this time, RedHat/Centos Linux v7.5+ and Ubuntu 18.04+ are supported. The currently executing user will be used to determine which cgroup configuration to apply.

Setting this to Disabled at the Server level will disable this setting server-wide. In all other cases, the Server level setting can be overridden at the Virtual Host level.

Default values:
Server level: Off
VH level: Inherit Server level setting

Syntax

Select from drop down list

reCAPTCHA Protection

Description

reCAPTCHA Protection is a service provided as a way to mitigate heavy server load. reCAPTCHA Protection will activate after one of the below situations is hit. Once active, all requests by NON TRUSTED(as configured) clients will be redirected to a reCAPTCHA validation page. After validation, the client will be redirected to their desired page.

The following situations will activate reCAPTCHA Protection:
1. The server or vhost concurrent requests count passes the configured connection limit.
2. Anti-DDoS is enabled and a client is hitting a url in a suspicious manner. The client will redirect to reCAPTCHA first instead of getting denied when triggered.
3. A new rewrite rule environment is provided to activate reCAPTCHA via RewriteRules. 'verifycaptcha' can be set to redirect clients to reCAPTCHA. A special value ': deny' can be set to deny the client if it failed too many times. For example, [E=verifycaptcha] will always redirect to reCAPTCHA until verified. [E=verifycaptcha: deny] will redirect to reCAPTCHA until Max Tries is hit, after which the client will be denied.

Enable reCAPTCHA

Description

Enable the reCAPTCHA Protection feature at the current level. This setting must be set to Yes at the Server level before the reCAPTCHA Protection feature can be used.

Default values:
Server-level: Yes
VH-Level: Inherit Server level setting

Syntax

Select from radio box

Site Key

Description

The site key is the public key provided by Google via its reCAPTCHA service. A default Site Key will be used if not set.

Secret Key

Description

The secret key is the private key provided by Google via its reCAPTCHA service. A default Secret Key will be used if not set.

reCAPTCHA Type

Description

Specify the reCAPTCHA type to use with the key pairs. If a key pair has not been provided and this setting is set to Not Set, a default key pair of type Invisible will be used.
Checkbox will display a checkbox reCAPTCHA for the visitor to validate.
Invisible will attempt to validate the reCAPTCHA automatically and if successful, will redirect to the desired page.

Default value is Invisible.

Syntax

Select from drop down list

Max Tries

Description

Max Tries specifies the maximum number of reCAPTCHA attempts permitted before denying the visitor.

Default value is 3.

Syntax

无符号整数

Allowed Robot Hits

Description

Number of hits per 10 seconds to allow ‘good bots’ to pass. Bots will still be throttled when the server is under load.

Default value is 3.

Syntax

无符号整数

Bot White List

Description

List of custom user agents to allow access. Will be subject to the ‘good bots’ limitations, including allowedRobotHits.

Syntax

List of user agents, one per line. Regex is supported.

Connection Limit

Description

The number of concurrent connections (SSL & non-SSL) needed to activate reCAPTCHA. reCAPTCHA will be used until concurrent connections drop below this number.

Default value is 15000.

Syntax

无符号整数

SSL Connection Limit

Description

The number of concurrent SSL connections needed to activate reCAPTCHA. reCAPTCHA will be used until concurrent connections drop below this number.

Default value is 10000.

Syntax

无符号整数

Bubblewrap Container

Description

Set to On if you wish to start CGI processes (including PHP programs) in a bubblewrap sandbox. See https://wiki.archlinux.org/index.php/Bubblewrap for details on using bubblewrap. Bubblewrap must be installed on your system prior to using this setting.

This setting cannot be turned on at the Virtual Host level if set to "Disabled" at the Server level.

Default values:
Server level: Disabled
VH level: Inherit Server level setting

Syntax

Select from drop down list

Bubblewrap Command

Description

The full bubblewrap use command, including the bubblewrap program itself. More on configuring this command can be found here: https://openlitespeed.org/kb/bubblewrap-in-openlitespeed/ . If not specified, the default command listed below will be used.

Default value: /bin/bwrap --ro-bind /usr /usr --ro-bind /lib /lib --ro-bind-try /lib64 /lib64 --ro-bind /bin /bin --ro-bind /sbin /sbin --dir /var --dir /tmp --proc /proc --symlink../tmp var/tmp --dev /dev --ro-bind-try /etc/localtime /etc/localtime --ro-bind-try /etc/ld.so.cache /etc/ld.so.cache --ro-bind-try /etc/resolv.conf /etc/resolv.conf --ro-bind-try /etc/ssl /etc/ssl --ro-bind-try /etc/pki /etc/pki --ro-bind-try /etc/man_db.conf /etc/man_db.conf --ro-bind-try /home/$USER /home/$USER --bind-try /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock --bind-try /home/mysql/mysql.sock /home/mysql/mysql.sock --bind-try /tmp/mysql.sock /tmp/mysql.sock --unshare-all --share-net --die-with-parent --dir /run/user/$UID ‘$PASSWD 65534’ ‘$GROUP 65534’

拒绝访问的目录

Description

指定应该拒绝访问的目录。 将包含敏感数据的目录加入到这个列表,以防止向客户端意外泄露敏感文件。 在路径后加一个“*”,可包含所有子目录。 如果跟随符号链接检查符号链接都被启用, 符号链接也将被检查是否在被拒绝访问目录中。

Syntax

逗号分隔的目录列表

Tips

[安全建议] 至关重要: 此设置只能防止服务这些目录中的静态文件。 这不能防止外部脚本如PHP、Ruby、CGI造成的泄露。

登入限制

Description

指定哪些子网络和/或IP地址可以访问该服务器。 这是影响所有的虚拟主机的服务器级别设置。您还可以为每个虚拟主机设置登入限制。虚拟主机的设置不会覆盖服务器设置。

是否阻止/允许一个IP是由允许列表与阻止列表共同决定。 如果你想阻止某个特定IP或子网,请在允许列表中写入*ALL,并在拒绝列表中写入需要阻止的IP或子网。 如果你想允许某个特定的IP或子网,请在拒绝列表中写入*ALL,并在允许列表中写入需要允许的IP或子网。 单个IP地址是被允许访问还是禁止访问取决于该IP符合的最小限制范围。

信任的IP或子网络可以在允许列表列表中添加后缀“T”来指定。受信任的IP或子网不受连接数/流量限制。 只有服务器级别的登入限制才可以设置受信任的IP或子网。

Tips

[安全建议] 用此项设置适用于所有虚拟主机的常规限制。

允许列表

Description

指定允许的IP地址或子网的列表。 可以使用{VAL}*或{VAL}ALL。

Syntax

逗号分隔的IP地址或子网列表。 结尾加上“T”可以用来表示一个受信任的IP或子网,如{VAL}192.168.1.*T。

Example

子网: 192.168.1.0/255.255.255.0, 192.168.1.0/24, 192.168.1192.168.1.*.
IPv6 地址: ::1[::1]
IPv6 子网: 3ffe:302:11:2:20f:1fff:fe29:717c/64[3ffe:302:11:2:20f:1fff:fe29:717c]/64.

Tips

[安全建议] 在服务器级别设置的受信任的IP或子网不受连接/节流限制。

拒绝列表

Description

指定不允许的IP地址或子网的列表。

Syntax

逗号分隔的IP地址或子网列表。 可以使用{VAL}*或{VAL}ALL。

Example

子网: 192.168.1.0/255.255.255.0, 192.168.1.0/24, 192.168.1192.168.1.*.
IPv6 地址: ::1[::1]
IPv6 子网: 3ffe:302:11:2:20f:1fff:fe29:717c/64[3ffe:302:11:2:20f:1fff:fe29:717c]/64.