配置 Liberty 設定檔的 Web 伺服器外掛程式

您可以配置 Web 伺服器外掛程式,以便在 Web 伺服器接收動態資源的 HTTP 要求時,會將要求轉遞給 Liberty 設定檔。

關於這項作業

Web 伺服器外掛程式用來將 HTTP 要求從支援的 Web 伺服器轉遞給一或多部應用程式伺服器。 外掛程式會取得要求,並對照 plugin-cfg.xml 檔中的配置資料來檢查要求。 配置資料會將 HTTP 要求的 URI 對映至應用程式伺服器的主機名稱。 之後,Web 伺服器外掛程式會利用這個資訊,將要求轉遞給應用程式伺服器。

程序

  1. 安裝支援的 Web 伺服器,例如 IBM® WebSphere® Application Server 隨附的 IBM HTTP Server。 請參閱安裝 IBM HTTP Server 適用於 IBM i 平台IBM i 提供的 Web 伺服器已安裝在產品 5761-DG1 (IBM i V6R1) 或 5770-DG1 (IBM i V7R1) 之下。 IBM i Web 伺服器稱為適用於 IBM i 的 IBM HTTP Server。WebSphere Application Server 隨附的 IBM HTTP Server 無法在 IBM i 上執行。
  2. 安裝 Web 伺服器外掛程式和 WebSphere Customization Toolbox (WCT)
  3. 適用於分散式平台利用 WCT 來配置您選擇的 Web 伺服器的 Web 伺服器外掛程式。
    • 當在 WCT 中出現提示時,請選擇「遠端」實務,然後指定可供存取 Liberty 設定檔的主機名稱。
    • 請勿複製及執行產生的 configureWebserver Script,因為 Liberty 設定檔不需要這個 Script。
  4. 啟動代管應用程式的伺服器,確認已將 localConnector-1.0 特性適用於 IBM i 平台(如果您在配置 IBM i 的外掛程式,則是 restConnector-1.0 特性)及其他必要的特性併到伺服器配置中。

    在伺服器配置檔的 pluginConfiguration 元素中,您可以指定 webserverPortwebserverSecurePort 屬性來轉遞 Web 伺服器發出的要求。 依預設,webserverPort 值是 80webserverSecurePort 值是 443。 不過,您可能會想要變更這些設定。 比方說,如果是 Linux 和類似的平台,且您是非 root 使用者,您必須使用大於 1024 的埠號。

    關於 pluginConfiguration 元素的所有可配置的屬性,請參閱 server.xml 檔中的配置元素

    以下是 server.xml 伺服器配置檔的範例:
    <server description="new server">
     <featureManager>
       <feature>localConnector-1.0</feature>
       <feature>jsp-2.2</feature>
     </featureManager>
      
    <keyStore id="defaultKeyStore" password="{xor}PGY6bW4wOyw+" />
    
     <httpEndpoint id="defaultHttpEndpoint"
                     host="*"
                     httpPort="9080">
              <tcpOptions soReuseAddr="true" />
         </httpEndpoint>
    
     <pluginConfiguration webserverPort="80"
                          webserverSecurePort="443"
                          sslKeyringLocation="path/to/sslkeyring"
                          sslStashfileLocation="path/to/stashfile"
                          sslCertlabel="definedbyuser"/>
    
     <application type="war" id="myapp" name="myapp" location="${server.config.dir}/apps/myapp.war" />
     <application type="war" id="snoop" name="snoop" location="${server.config.dir}/apps/snoop.war" />
    </server>

    適用於 IBM i 平台對於 IBM i,請併入 restConnector-1.0 特性,而不是 localConnector-1.0 特性。 如需詳細資料,請參閱配置通往 Liberty 設定檔的安全 JMX 連線

    適用於 IBM i 平台以下是適用於 IBM i 的 server.xml 伺服器配置檔範例:
    <server description="new server">
    
    <!-- Enable features -->
      <featureManager>
         <feature>jsp-2.2</feature>
         <feature>restConnector-1.0</feature>
      </featureManager>
    
    <keyStore id="defaultKeyStore" password="{xor}PGY6bW4wOyw+" />
    
     <httpEndpoint id="defaultHttpEndpoint"
                     host="*"
                     httpPort="9080"
                     httpsPort="9443">
              <tcpOptions soReuseAddr="true" />
         </httpEndpoint>
    
    <quickStartSecurity userName="testuser"
     						userPassword="security" />
    
     <pluginConfiguration webserverPort="80"
                          webserverSecurePort="443"
                          sslKeyringLocation="path/to/sslkeyring"
                          sslStashfileLocation="path/to/stashfile"
                          sslCertlabel="definedbyuser"/>
    
     <application type="war" id="myapp" name="myapp" location="${server.config.dir}/apps/myapp.war" />
     <application type="war" id="snoop" name="snoop" location="${server.config.dir}/apps/snoop.war" />
    </server>
    註:
    • 如果您配置 Web 伺服器外掛程式來使用 SSL,您必須啟用 Liberty 設定檔的 ssl-1.0 Liberty 特性。
    • 如果 Web 伺服器使用預設埠,您不需要在 server.xml 檔中併入 pluginConfiguration 元素。
    • Web 伺服器外掛程式所用的金鑰儲存庫必須是可以利用「金鑰管理 (iKeyman)」公用程式來建立的 CMS 金鑰儲存庫。 您無法將 Liberty 設定檔或 完整設定檔 所建立的 JKS 金鑰儲存庫用於 Web 伺服器外掛程式,但您必須在 Web 伺服器外掛程式金鑰儲存庫和 Liberty 設定檔金鑰儲存庫之間交換簽章者憑證。
    • 如果要配置外掛程式日誌檔的位置,請新增下列程式碼 Snippet 到 server.xml 檔中:
      <Log LogLevel="Error" Name="String\logs\String\http_plugin.log"/>
      [8.5.5.6 或更新版本]
      <Log LogLevel="Error" Name="/path to log file/http_plugin.log"/>
  5. 呼叫 WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig MBean 來產生您的 Liberty 設定檔伺服器和應用程式的 plugin-cfg.xml 檔。
    1. 利用與伺服器相同的 Java SDK,在指令視窗中執行 jconsole Java 公用程式。
      例如,執行下列指令:
      c:\java\bin\jconsole
      伺服器程序會列在等待連線的選項中。
      對於 IBM i,請利用隨著 WCT 而安裝於工作台的 Java SDK,從指令視窗執行 jconsole Java 公用程式。 比方說,請完成下列步驟:
      1. 在工作台上,建立 C:\restClient 目錄。
      2. ${wlp.install.dir}/clients/restConnector.jar 複製到工作台的 C:\restClient 目錄。
      3. ${server.output.dir}/resources/security/key.jks 複製到工作台的 C:\restClient 目錄。
      4. 在指令視窗中,輸入 SET JAVA_HOME=wct_root\java
        註: 暫時修改 wct_root\java\jre\lib\security\java.security,註銷將 SSL Socket Factory 設為 WebSphere Application Server SSL Socket Factory 的那兩行。此修改記載在「疑難排解提示」主題的 SSL 疑難排解小節中。
      5. 從相同的指令視窗中,執行 jconsole Java 公用程式。
        例如,執行下列指令:
        "%JAVA_HOME%"\bin\jconsole -J-Djava.class.path="%JAVA_HOME%"\lib\jconsole.jar;"%JAVA_HOME%"\lib\tools.jar;
        C:\restClient\restConnector.jar -J-Djavax.net.ssl.trustStore=C:\restClient\key.jks
         -J-Djavax.net.ssl.trustStorePassword=Liberty -J-Djavax.net.ssl.trustStoreType=jks
        您也可能需要下列參數:
        -J-Dcom.ibm.ws.jmx.connector.client.disableURLHostnameVerification=true
    2. 連接到您的伺服器,然後按一下 MBean 標籤。 適用於 IBM i 平台jConsole 啟動之後,請選取遠端程序,然後輸入 JMX 服務 URL:service:jmx:rest://<host>:<port>/IBMJMXConnectorREST。 埠號是 HTTPS 埠。 另外,您也必須提供使用者名稱和密碼。
    3. WebSphere 網域之下,尋找 com.ibm.ws.jmx.mbeans.generatePluginConfig MBean。
    4. 呼叫 generateDefaultPluginConfig 作業來產生 plugin-cfg.xml 檔,或在產生 plugin-cfg.xml 檔之前,呼叫 generatePluginConfig 作業來自訂安裝根目錄和伺服器名稱。
    以下是 plugin-cfg.xml 檔的範例:
    <?xml version="1.0" encoding="UTF-8"?>
    <Config ASDisableNagle="false" AcceptAllContent="false" AppServerPortPreference="HostHeader"
            ChunkedResponse="false" FIPSEnable="false" IISDisableNagle="false"
            IISPluginPriority="High" IgnoreDNSFailures="false" RefreshInterval="60"
            ResponseChunkSize="64" SSLConsolidate="false" SSLPKCSDriver="REPLACE"
            SSLPKCSPassword="REPLACE" TrustedProxyEnable="false" VHostMatchingCompat="false">
       <Log LogLevel="Error" Name=".\logs\defaultServer\http_plugin.log"/>
       <Property Name="ESIEnable" Value="true"/>
       <Property Name="ESIMaxCacheSize" Value="1024"/>
       <Property Name="ESIInvalidationMonitor" Value="false"/>
       <Property Name="ESIEnableToPassCookies" Value="false"/>
       <Property Name="PluginInstallRoot" Value="."/>
       <VirtualHostGroup Name="default_host">
             <VirtualHost Name="*:80"/>
             <VirtualHost Name="*:443"/>
             <VirtualHost Name="*:9080"/>
         </VirtualHostGroup>
     <ServerCluster CloneSeparatorChange="false" GetDWLMTable="false" IgnoreAffinityRequests="true"
                    LoadBalance="Round Robin" Name="defaultServer_default_node_Cluster"
                    PostBufferSize="64" PostSizeLimit="-1" RemoveSpecialHeaders="true"
                    RetryInterval="60">
          <Server CloneID="b564bdc7-2c27-4a4b-ad37-9213c66e60d1" ConnectTimeout="0"
                  ExtendedHandshake="false" MaxConnections="-1" Name="default_node_defaultServer0"
                  ServerIOTimeout="900" WaitForContinue="false">
              <Transport Hostname="somehost.example.com" Port="9080" Protocol="http"/>
             </Server>
          <PrimaryServers>
              <Server Name="default_node_defaultServer0"/>
             </PrimaryServers>
        </ServerCluster>
     <UriGroup Name="default_host_defaultServer_default_node_Cluster_URIs">
          <Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/myapp/*"/>
          <Uri AffinityCookie="JSESSIONID" AffinityURLIdentifier="jsessionid" Name="/snoop/*"/>
        </UriGroup>
     <Route ServerCluster="defaultServer_default_node_Cluster"
            UriGroup="default_host_defaultServer_default_node_Cluster_URIs"
            VirtualHostGroup="default_host"/>
    </Config>
    plugin-cfg.xml 檔是產生在 ${server.output.dir} 目錄中。
    註:
    • 您可以搭配 Liberty 設定檔來使用 jConsole 公用程式。 不過,公用程式本身若有任何問題,都必須向 Java SDK 提供者報告。
    • WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig MBean 的管理介面是 com.ibm.websphere.webcontainer.GeneratePluginConfigMBean您可以利用管理介面來取得虛擬物件。請參閱 存取 MBean 屬性和作業的範例 如需管理介面的相關資訊,請參閱 Liberty 設定檔的 Java API 文件。每一個 Liberty 設定檔 API 的 Java API 文件都詳述於資訊中心的程式設計介面 (API) 區段,也以個別的 .zip 檔來提供(其位於 ${wlp.install.dir}/dev 目錄下的其中一個 javadoc 子目錄中)。
  6. plugin-cfg.xml 檔複製到管理 Web 伺服器的機器。 適用於 IBM i 平台對於 IBM i,請完成下列步驟:
    1. 執行 manageprofiles Qshell 指令來建立 HTTP 設定檔。 例如,plugins_root/bin/manageprofiles -create -profileName http -templatePath http.
    2. plugin-cfg.xml 檔複製到子步驟 a 所建立之 HTTP 設定檔的 config 目錄中,例如 plugin_profile_root/config/plugin-cfg.xml,然後設定檔案許可權。
    3. 從系統指令行執行下列指令,將檔案權限變更為所需要的設定:
      CHGAUT USER(QEJBSVR QTMHHTTP QNOTES) OBJ('plugin_profile_root/config/plugin-cfg.xml') DTAAUT(*RWX)
  7. 適用於 IBM i 平台配置 HTTP 伺服器來使用 plugin-cfg.xml 檔。

    在 HTTP 伺服器的配置檔尾端,找出指定給 WebSpherePluginConfig 指引的值來尋找現行 plugin-cfg.xml 的位置。 例如,<IHS_ROOT>/conf/httpd.conf

    請利用 LoadModule 詞組,在 Web 伺服器的 httpd.conf 檔內啟用外掛程式,然後利用 WebSpherePluginConfig 詞組來指定 plugin-cfg.xml 檔的位置。 例如:
    • 在 Windows 系統上:適用於 Windows 平台
      LoadModule was_ap22_module "path/to/mod_was_ap22_http.dll"
      WebSpherePluginConfig "C:\Program Files\IBM\HTTPServer\conf\plugin-cfg.xml"
    • 其他分散式系統:適用於 AIX 平台適用於 LINUX 平台適用於 UNIX 平台適用於 HP UNIX 平台適用於 Solaris 平台適用於 IBM i 平台
      LoadModule was_ap22_module "path/to/mod_was_ap22_http.so"
      WebSpherePluginConfig "/opt/IBM/HTTPServer/conf/plugin-cfg.xml"

    適用於 IBM i 平台若為 IBM i,請參閱配置 IBM HTTP Server(採用 Apache 2.x 技術),以取得在 httpd.conf 檔內啟用外掛程式的指示。

  8. 選擇性的: 如果您想要 Web 伺服器外掛程式將 HTTP 要求轉遞給多個 Liberty 設定檔伺服器,請重複前面的步驟來處理其他各伺服器。 請務必將所有外掛程式配置合併到單一 plugin-cfg.xml 檔中。
    註:

指示主題類型的圖示 作業主題

資訊中心條款 | 意見


「時間戳記」圖示 前次更新: 2015 年 6 月 22 日
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-libcore-mp&topic=twlp_admin_webserver_plugin
檔名:twlp_admin_webserver_plugin.html