Skip to main content

This documentation is for an older version of this product. See the latest version of this content.Opens in a new tab

ロック・ダウン Apache (UNIX®/Linux/macOS)

Apache がロック・ダウンされているために、Apache ファイル・システムの外部のファイルにアクセスするようにサーバを簡単に構成できない場合があります。例えば、Security Enhanced Linux (SELinux) の場合です。

このようなロック・ダウンの構成では、別途説明した Web ゲートウェイ構成で CSP リソースにアクセスしようとすると、HTTP 403 Forbidden のエラー・コードが返されます。この問題に対処するための戦略は 2 つあります。

  • Web ゲートウェイのホーム・ディレクトリのセキュリティ・コンテキストを変更して、Apache がこの場所に保存されているファイルにアクセスできるようにします。

  • Web ゲートウェイのホーム・ディレクトリを Apache ルート・ファイル・システムの下の場所 (SELinux の設定では、Apache がアクセスできるように事前構成されています) に移動します。

まず、Web ゲートウェイのホーム・ディレクトリに対する SELinux のセキュリティ・コンテキストを変更します。これは通常は簡単な作業であり、以下の手順が含まれます。

ここでは、例として Web ゲートウェイのホーム・ディレクトリ /opt/webgateway/bin、ポート 1972 で待ち受ける InterSystems IRIS スーパーサーバ、および /usr/iris/ にインストールされている InterSystems IRIS を使用します。

chcon コマンドでファイル・コンテキストを設定します。変更は直ちに有効になります。

sudo chcon -R -t httpd_sys_content_t /usr/iris/csp
sudo chcon -R -t httpd_sys_rw_content_t /opt/webgateway/conf/CSP.ini
sudo chcon -R -t httpd_sys_rw_content_t /opt/webgateway/conf/CSPRT.ini
sudo chcon -R -t httpd_sys_rw_content_t /opt/webgateway/logs/CSP.log
sudo chcon -t httpd_modules_t /opt/webgateway/bin/CSPa2.so
sudo chcon -t httpd_modules_t /opt/webgateway/bin/CSPa2Sys.so
sudo chcon -t httpd_modules_t /opt/webgateway/bin/CSPa22.so
sudo chcon -t httpd_modules_t /opt/webgateway/bin/CSPa22Sys.so
sudo chcon -t httpd_modules_t /opt/webgateway/bin/CSPa24.so
sudo chcon -t httpd_modules_t /opt/webgateway/bin/CSPa24Sys.so

ただし、chcon コマンドで行った変更は、次回ラベルを再適用すると失われます。このため、chcon のほかに semanagefcontext 機能を使用する必要があります。以下のコマンドを使用すると、SELinux が強制されているときに、Web ゲートウェイを実行できます。

semanage fcontext -a -t lib_t "/opt/webgateway/bin/(.*\.so)?" 2> /dev/null
semanage fcontext -a -t httpd_sys_rw_content_t "/opt/webgateway/bin/temp(/.*)?" 2> /dev/null
semanage fcontext -a -t httpd_sys_rw_content_t "/opt/webgateway/bin/CSP(.*\.ini)?" 2> /dev/null
semanage fcontext -a -t httpd_sys_rw_content_t "/opt/webgateway/bin/CSP.log" 2> /dev/null
restorecon -vr /opt/webgateway/bin > /dev/null

次に、以下のコマンドを使用します。スーパーサーバ・ポートのコンテキストを正しく設定することが非常に重要です。そうしないと、Web ゲートウェイはポートにアクセスできず、"サーバが利用可能でありません" というエラーが返されます。

sudo /usr/sbin/semanage fcontext -a -t httpd_sys_content_t
    "/usr/iris/csp(/.)?"
sudo /usr/sbin/semanage fcontext -a -t httpd_sys_rw_content_t
    "/opt/webgateway/conf/CSP.ini"
sudo /usr/sbin/semanage fcontext -a -t httpd_sys_rw_content_t
    "/opt/webgateway/conf/CSPRT.ini"
sudo /usr/sbin/semanage fcontext -a -t httpd_sys_rw_content_t
    "/opt/webgateway/logs/CSP.log"
sudo /usr/sbin/semanage fcontext -a -t httpd_modules_t
    "/opt/webgateway/bin/CSPa2.so"
sudo /usr/sbin/semanage fcontext -a -t httpd_modules_t
    "/opt/webgateway/bin/CSPa2Sys.so"
sudo /usr/sbin/semanage fcontext -a -t httpd_modules_t
    "/opt/webgateway/bin/CSPa22.so"
sudo /usr/sbin/semanage fcontext -a -t httpd_modules_t
   "/opt/webgateway/bin/CSPa22Sys.so"
sudo /usr/sbin/semanage fcontext -a -t httpd_modules_t
    "/opt/webgateway/bin/CSPa24.so"
sudo /usr/sbin/semanage fcontext -a -t httpd_modules_t
    "/opt/webgateway/bin/CSPa24Sys.so"
sudo /usr/sbin/semanage port -a -t http_port_t -p tcp 51773

これらは、Web ゲートウェイ (Apache サーバをホストするコンテキストで動作している) にホーム・ディレクトリ内のファイルへのアクセス権を付与する基本的な手順です。

Apache で提供されている事前構成されたディレクトリで機能するように Web ゲートウェイを構成する方法もあります。これは、上記の方法を利用できない場合に使用すべき方法です。以下のコマンドは、Apache が /usr/apache にインストールされていることを前提としています。

  • CGI モジュールを /usr/apache/cgi-bin/ にコピーする必要があります

    cp /usr/iris/csp/bin/*cgi* /usr/apache/cgi-bin/
    
  • API モジュールを /usr/apache/modules/ にコピーする必要があります

    cp /usr/iris/csp/bin/*.so /usr/apache/modules/
    
  • 静的ファイルを /usr/apache/htdocs/ の下層の場所にコピーする必要があります

    cp /usr/iris/csp/samples/* /usr/apache/htdocs/csp/samples/
    cp /usr/iris/csp/broker/* /usr/apache/htdocs/csp/broker/
    cp /usr/iris/csp/sys/* /usr/apache/htdocs/csp/sys/
    

    さらに、上記の場所の下にあるサブディレクトリをコピーします。

Web ゲートウェイのインストールを移動した後、Apache 構成で指定したパスを適切に変更します。

推奨オプション : Apache API モジュール (CSPa24.so)

LoadModule cspsys_module_sa /usr/apache/modules/CSPap24.so
CSPSYSModulePath /usr/apache/modules/
CSPFileTypes csp cls zen cxw

代替オプション 1 : NSD を使用した Apache API モジュール (mod_csp.so)

LoadModule csp_module /usr/apache/modules/mod_csp.so
CSPFileTypes csp cls zen cxw 
ScriptAliasMatch /csp/bin/Systems/Module.cxw "/usr/apache/cgi-bin/nph-CSPcgiSys" 
ScriptAliasMatch /csp/bin/RunTime/Module.cxw "/usr/apache/cgi-bin/nph-CSPcgi"

代替オプション 2 : NSD を使用した CGI モジュール (nph-CSPcgi)

<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 "/usr/apache/cgi-bin/nph-CSPcgiSys" 
ScriptAliasMatch /csp/bin/RunTime/Module.cxw "/usr/apache/cgi-bin/nph-CSPcgi"
ScriptAliasMatch /*\.([Cc][Ss][Pp]|[Cc][Ll][Ss])$ "/usr/apache/cgi-bin/nph-CSPcgi"

代替オプション 3 : NSD を使用した組み込み Apache API モジュール (mod_csp.c)

CSPFileTypes csp cls zen cxw 
ScriptAliasMatch /csp/bin/Systems/Module.cxw "/apache/cgi-bin/nph-CSPcgiSys" 
ScriptAliasMatch /csp/bin/RunTime/Module.cxw "/usr/apache/cgi-bin/nph-CSPcgi"
FeedbackOpens in a new tab