第七十三章 Apache (UNIX® Linux macOS) 的替代选项 - 替代选项 2:带有 NSD 的 CGI 模块 (nph-CSPcgi)

发布于:2024-05-10 ⋅ 阅读:(285) ⋅ 点赞:(0)

第七十三章 Apache (UNIX® Linux macOS) 的替代选项 - 替代选项 2:带有 NSD 的 CGI 模块 (nph-CSPcgi)

替代选项 2:带有 NSD 的 CGI 模块 (nph-CSPcgi)

Web 服务器应配置为能够识别文件类型并将它们传递到 Web 网关进行处理。

Web 服务器配置文件 (httpd.conf) 位于以下目录中:

/usr/apache/conf

对于 Red Hat Linux,httpd.conf 的运行时版本位于:

/etc/httpd/conf

将以下部分添加到 httpd.conf 的末尾:

<LocationMatch "/*\.([Cc][Ss][Pp]|[Cc][Ll][Ss]|[Zz][En][Nn])$">
    AllowOverride None
    Options FollowSymLinks ExecCGI
    Require all granted
</LocationMatch>
ScriptAliasMatch /csp/bin/Systems/Module.cxw "/opt/webgateway/bin/nph-CSPcgiSys" 
ScriptAliasMatch /csp/bin/RunTime/Module.cxw "/opt/webgateway/bin/nph-CSPcgi"
ScriptAliasMatch /*\.([Cc][Ss][Pp]|[Cc][Ll][Ss])$ "/opt/webgateway/bin/nph-CSPcgi"
Alias /csp/ instance-installation-directory
<Directory "instance-installation-directory">
    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 环境可用的正则表达式 (regex) 处理器。有时情况并非如此,因此不会提供 CSP 文件(返回文件未找到错误)。为了解决这种情况,您可以将 Web 应用程序的(虚拟)根位置与 CGI 模块关联,而不是通过 CSP 文件扩展名进行关联。例如,您的 Web 应用程序包含在 /csp 中。要将 CSP CGI 模块与 /csp 下的文件关联,请替换以下配置块:

<LocationMatch "/*\.([Cc][Ss][Pp]|[Cc][Ll][Ss]|[Zz][En][Nn])$">
    AllowOverride None
    Options FollowSymLinks ExecCGI
    Require all granted
</LocationMatch>
ScriptAliasMatch /*\.([Cc][Ss][Pp]|[Cc][Ll][Ss])$ "/opt/webgateway/bin/nph-CSPcgi"

<Location "/csp">
    AllowOverride None
    Options FollowSymLinks ExecCGI
   Require all granted
</Location>
ScriptAlias /csp "/opt/webgateway/bin/nph-CSPcgi"

这些指令适用于以下形式的 URL:

http://localhost:<port_no>/csp/*.csp

复制其他根位置的配置块。例如,针对以下形式的 URL 对 /myapps 重复该过程:

http://localhost:<port_no>/myapps/*.csp

避免正则表达式问题的另一种方法是将 Action 指令与 CSP MIME 类型结合使用。但是,应该注意的是,Action 本质上是一种内容过滤技术,因此,即使 IRIS 服务器安装在单独的计算机上,也要求CSP 文件实际存在于 Web 服务器主机上。如果您希望使用此方法,请首先将新的 MIME 类型添加到 Apache mime.types 文件的末尾,并将其与表示 CSP 内容的文件类型相关联。 mime.types 文件与 httpd.conf 文件位于同一目录中。

text/csp                csp cls

现在,将 Action 指令添加到 httpd.conf 中 CGI 配置块的末尾,如下所示:

Alias /csp/ /opt/webgateway/csp/
<Directory "/opt/webgateway/csp">
    AllowOverride None
    Options MultiViews FollowSymLinks ExecCGI
    Require all granted
<Files CSPnsd>
       Require all denied
    </Files>
<Files CSP.ini>
       Require all denied
    </Files>
<Files CSP.log>
       Require all denied
    </Files>
<Files CSPnsd.ini>
       Require all denied
    </Files>
<Files CSPnsd.pid>
       Require all denied
    </Files>
</Directory>
ScriptAlias /csp-bin/ "/opt/webgateway/bin/"
<Directory "/opt/webgateway/bin/">
    AllowOverride None
    Options None
    Require all granted
</Directory>
Action text/csp “/csp-bin/nph-CSPcgi”

更改 httpd.conf 后重新启动 Apache。

最后,请注意,由于 CGI 是开放标准,因此 CSP CGI 模块适用于任何 Web 服务器。

映射其他文件类型

Apache API 模块始终识别 InterSystems 文件类型。对于其他文件扩展名,请参阅配置 Apache 以传递其他文件类型。

使用 CGI 和 NSD 操作和管理 Web 网关

此连接选项取决于 Web Gateway 的网络服务守护程序 (NSD)。

  1. 按照操作 NSD 中的说明启动 CSP NSD
  2. 更改其配置 (httpd.conf) 后重新启动 Apache。Apache 和 NSD 的启动顺序并不重要。
  3. 要访问 Web Gateway 管理页面,请在浏览器中输入以下 URL 之一。
http://localhost:<port_no>/csp/bin/Systems/Module.cxw 
http://localhost:<port_no>/csp-bin/nph-CSPcgiSys

如果看到未经授权的用户错误消息,请参阅启用来自其他客户端地址的访问。


微信公众号

今日签到

点亮在社区的每一天
去签到