第七十四章 Apache (UNIX® Linux macOS) 的替代选项 - 替代选项 3:带有 NSD 的内置 Apache API 模块 (mod_csp.c)
在开始设置这个更复杂的选项之前,应该记住,对于大多数现代 UNIX® 系统,静态链接相对于在运行时将模块链接为共享对象(选项 1)的性能优势是最小的(如果有的话) )。
请务必结合 Apache 发行版中包含的特定文档来阅读这些说明。
构建 Apache 以包含 CSP 模块源代码
有关此步骤,请参阅 Apache 文档。
http://httpd.apache.org/
检查生成的 Apache 二进制文件
运行以下命令检查CSP模块是否已成功包含在Apache核心中(此命令列出了Apache当前内置的所有模块):
./httpd -l
例如:
Compiled in modules:
core.c
mod_access.c
mod_auth.c
mod_include.c
mod_log_config.c
mod_env.c
mod_setenvif.c
prefork.c
http_core.c
mod_mime.c
mod_status.c
mod_autoindex.c
mod_asis.c
mod_cgi.c
mod_negotiation.c
mod_dir.c
mod_imap.c
mod_actions.c
mod_userdir.c
mod_alias.c
mod_csp.c
运行时配置
编辑 Apache 配置文件 httpd.conf。对于标准 Apache 发行版,此文件位于:
/usr/apache/conf
对于 Red Hat Linux,httpd.conf 的运行时版本位于:
/etc/httpd/conf
假设\希望为包含 .csp、.cls 或 .zen 扩展名的请求文件调用 CSP 引擎,请将以下部分添加到 httpd.conf 的末尾:
CSPFileTypes csp cls zen cxw
ScriptAliasMatch /csp/bin/Systems/Module.cxw "/opt/webgateway/bin/nph-CSPcgiSys"
ScriptAliasMatch /csp/bin/RunTime/Module.cxw "/opt/webgateway/bin/nph-CSPcgi"
Alias /csp/ /opt/webgateway/csp/
<Directory "/opt/webgateway/csp">
AllowOverride None
Options MultiViews FollowSymLinks ExecCGI
Require all granted
<FilesMatch "\.(log|ini|pid|exe)$">
Require all denied
</FilesMatch>
<Files CSPnsd>
Require all denied
</Files>
</Directory>
ScriptAlias /csp-bin/ "/opt/webgateway/bin/"
<Directory "/opt/webgateway/bin/">
AllowOverride None
Options None
Require all granted
</Directory>
请注意,对 Apache 的所有请求均由按预定义顺序调用的一组模块提供服务。 CSP 模块是最先调用的模块之一,前提是其定义按照建议添加到配置文件末尾附近。
更改 httpd.conf 后重新启动 Apache。
映射其他文件类型
Apache API 模块始终识别 文件类型。对于其他文件扩展名,请参阅配置 Apache 以传递其他文件类型。
使用 Apache API 和 NSD 操作和管理 Web 网关
此连接选项取决于 Web Gateway 的网络服务守护程序 (NSD)。
- 按照操作
NSD中的说明启动CSP NSD。 - 更改其配置 (
httpd.conf) 后重新启动Apache。
Apache 和 NSD 的启动顺序并不重要。
- 要访问
Web Gateway管理页面,请将浏览器指向以下位置之一。
http://localhost:<port_no>/csp/bin/Systems/Module.cxw
http://localhost:<port_no>/csp-bin/nph-CSPcgiSys
如果看到未经授权的用户错误消息,请参阅启用来自其他客户端地址的访问。