使用 MBean 生成 plugin-cfg.xml 文件

您可以通过调用 WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig MBean,为 Web 服务器生成 plugin-cfg.xml 文件。

开始之前

[16.0.0.3 and later]从 16.0.0.3 开始,不需要生成 plugin-cfg.xml 文件。产品会自动生成此文件。请参阅自动生成 plugin-cfg.xml 文件

如果应用程序使用 Servlet 3.0 API 以编程方式修改会话 Cookie 配置,那么在生成 plugin-cfg.xml 文件之前,必须初始化该应用程序。否则,对该应用程序定义的 AffinityCookie 属性可能存在错误。要避免此问题,可以deferServletLoad 设置为 false,启动服务器,生成插件,然后移除 deferServletLoad 属性。

关于此任务

使用 Web 服务器插件将 HTTP 请求从支持的 Web 服务器转发到一个或多个应用程序服务器。插件接受请求并根据 plugin-cfg.xml 文件中的配置数据来检查请求。配置数据将 HTTP 请求的 URI 映射到应用程序服务器的主机名。Web 服务器插件随后使用此信息将请求转发到应用程序服务器。

过程

  1. 启动托管应用程序的服务器,并确保 localConnector-1.0 功能部件(对于 IBM® i 和 z/OS® 平台)或 restConnector-1.0 功能部件(如果您要为 IBM i 或 z/OS 配置插件)及所有其他必需功能部件包括在服务器配置中。

    在服务器配置文件的 pluginConfiguration 元素中,可以指定 webserverPortwebserverSecurePort 属性以转发来自 Web 服务器的请求。缺省情况下,webserverPort 的值为 80,而 webserverSecurePort 的值为 443。但是,您可能需要更改这些设置。例如,对于 Linux 及类似平台,如果您是非 root 用户,那么必须使用大于 1024 的端口号。

    有关 pluginConfiguration 元素的所有可配置属性,请参阅 Java Servlets 3.1

    下面举例说明了 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>

    For IBM i platforms对于 IBM i 和 z/OS,请包括 restConnector-1.0 功能部件而不是 localConnector-1.0 功能部件。有关详细信息,请参阅配置与 Liberty 的安全 JMX 连接

    For IBM i platforms以下是 IBM i 和 z/OS 的 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,那么必须启用 Libertyssl-1.0 Liberty 功能部件。
    • 如果 Web 服务器是使用缺省端口,那么不必在 server.xml 文件中包括 pluginConfiguration 元素。
    • Web 服务器插件使用的密钥库必须是 CMS 密钥库,该密钥库可以使用密钥管理 (iKeyman) 实用程序来创建。尽管您必须在 Web 服务器插件密钥库与 Liberty 密钥库之间交换签署者证书,但您不能对 Web 服务器插件使用 Liberty 或传统版创建的 JKS 密钥库。
    • 要配置插件日志文件的位置,请将下列代码段添加到 server.xml 文件的 pluginConfiguration 元素中:
      logDirLocation=/path/to/log/file/
  2. 通过调用 WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig MBean,为 Liberty 服务器和应用程序生成 plugin-cfg.xml 文件。
    1. 在命令窗口中使用和服务器相同的 Java SDK 来运行 jconsole Java 实用程序。
      例如,运行以下命令:
      c:\java\bin\jconsole
      服务器进程列示在等待连接的选项中。
      For IBM i platforms对于 IBM i 和 z/OS,请使用通过 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 套接字工厂设置为 WebSphere® Application Server SSL 套接字工厂的两行注释掉。在“故障诊断技巧”主题的对 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. 连接至服务器,然后单击 MBeans 选项卡。 For IBM i platforms在 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>
    ${server.output.dir} 目录中生成 plugin-cfg.xml 文件。
    注:
    • 可将 jConsole 实用程序与 Liberty 配合使用。但是,与该实用程序本身相关的任何问题必须报告给 Java SDK 提供者。
    • WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig MBean 的管理接口是 com.ibm.websphere.webcontainer.GeneratePluginConfigMBean
  3. plugin-cfg.xml 文件复制到托管 Web 服务器的机器。 For IBM i platforms对于 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)

用于指示主题类型的图标 任务主题

文件名:twlp_generate_plugin_cfg_xml_mbean.html