24.9. Microsoft ISAPI 连接器

Internet 服务器 API(ISAPI)是一组 API,用于为 Web 服务器(如 Microsoft 的 Internet Information Services(IIS))编写 OLE 服务器扩展和过滤器。isapi_redirect.dllmod_jk 的扩展,调整为 IIS。isapi_redirect.dll 允许您将 JBoss EAP 实例配置为将 IIS 用作负载平衡器的 worker 节点。

注意

如需有关 Windows Server 和 IIS 支持的配置 的信息,请参阅 JBoss EAP 支持的配置。

24.9.1. 将 Microsoft IIS 配置为使用 ISAPI 连接器

从红帽客户门户网站下载 ISAPI 连接器:

  1. 打开浏览器并登录红帽客户门户 JBoss 软件下载页面
  2. Product 下拉菜单中选择 Web Connectors
  3. Version 下拉菜单中选择最新的 JBoss Core Services 版本。
  4. 在列表中找到 Red Hat JBoss Core Services ISAPI Connector,然后单击 Download 链接。
  5. 提取存档,并将 sbin 目录的内容复制到服务器的一个位置。以下说明假定内容已复制到 C:\connectors\

使用 IIS Manager(IIS 7)配置 IIS 重定向器:

  1. StartRun 并输入 inetmgr 来打开 IIS 管理器。
  2. 在左侧的树视图窗格中,展开 IIS 7
  3. 双击 ISAPI 和 CGI 注册以 在新窗口中将其打开。
  4. Actions 窗格中,单击 Add。此时将打开 Add ISAPI 或 CGI Restriction 窗口。
  5. 指定以下值:

    • ISAPI 或 CGI 路径C:\connectors\isapi_redirect.dll
    • 描述jboss
    • 允许执行扩展路径 :选中复选框。
  6. 单击 确定 以关闭 添加 ISAPI 或 CGI Restriction 窗口。
  7. 定义 JBoss 原生虚拟目录

    • 右键单击 Default Web Site,再单击 Add Virtual Directory。此时将打开 Add Virtual Directory 窗口。
    • 指定以下值来添加虚拟目录:

      • 别名jboss
      • 物理路径C:\connectors\
    • 单击 OK 以保存这些值并关闭 Add Virtual Directory 窗口。
  8. 定义 JBoss 原生 ISAPI 重定向过滤器

    • 在树视图窗格中,展开 SitesDefault Web Site
    • 双击 ISAPI 过滤器。此时 会显示 ISAPI 过滤器功能 视图。
    • Actions 窗格中,单击 Add。此时 将显示 Add ISAPI Filter 窗口。
    • Add ISAPI Filter 窗口中指定以下值:

      • 过滤器名称jboss
      • 可执行C:\connectors\isapi_redirect.dll
    • 单击 OK 以保存这些值并关闭 Add ISAPI Filters 窗口。
  9. 启用 ISAPI-dll 处理程序

    • 双击树视图窗格中的 IIS 7 项目。IIS 7 Home Features View 将打开。
    • 双击 Handler 映射。Handler 映射功能视图 显示。
    • Group by combo 框中,选择 StateHandler Mappings 显示在 Enabled 和 Disabled Groups 中。
    • 查找 ISAPI-dll.如果它位于 Disabled 组中,请右键单击它,然后选择 Edit Feature Permissions
    • 启用以下权限:

      • 脚本
      • 执行
    • 单击 OK 以保存这些值,然后关闭 Edit Feature Permissions 窗口。

Microsoft IIS 现已配置为使用 ISAPI 连接器。

24.9.2. 配置 ISAPI 连接器以将客户端请求发送到 JBoss EAP

此任务配置一组 JBoss EAP 服务器,以接受来自 ISAPI 连接器的请求。它不包括用于负载平衡或高可用性故障转移的配置。

此配置在 IIS 服务器上完成,并且假定您已将 JBoss EAP 配置为 接受来自外部 Web 服务器的请求。您还需要对 IIS 服务器的完整管理员访问权限,并将 IIS 配置为使用 ISAPI 连接器

创建属性文件和设置重定向
  1. 创建用于存储日志、属性文件和锁定文件的目录。

    此流程的其余部分假定您为此使用了目录 C:\connectors\。如果您使用不同的目录,请相应地修改说明。

  2. 创建 isapi_redirect.properties 文件。

    创建名为 C:\connectors\isapi_redirect.properties 的新文件。将以下内容复制到 文件。

    # Configuration file for the ISAPI Connector
    # Extension uri definition
    extension_uri=/jboss/isapi_redirect.dll
    
    # Full path to the log file for the ISAPI Connector
    log_file=c:\connectors\isapi_redirect.log
    
    # Log level (debug, info, warn, error or trace)
    log_level=info
    
    # Full path to the workers.properties file
    worker_file=c:\connectors\workers.properties
    
    # Full path to the uriworkermap.properties file
    worker_mount_file=c:\connectors\uriworkermap.properties
    
    #Full path to the rewrite.properties file
    rewrite_rule_file=c:\connectors\rewrite.properties

    如果您不想使用 rewrite.properties 文件,请在行首加上 # 字符来注释掉最后一行。

  3. 创建 uriworkermap.properties 文件

    uriworkermap.properties 文件包含已部署应用程序 URL 之间的映射,以及哪个 worker 处理向它们的请求。下例中的 文件显示了 文件的语法。将您的 uriworkermap.properties 文件放在 C:\connectors\ 中。

    # images and css files for path /status are provided by worker01
    /status=worker01
    /images/*=worker01
    /css/*=worker01
    
    # Path /web-console is provided by worker02
    # IIS (customized) error page is used for http errors with number greater or equal to 400
    # css files are provided by worker01
    /web-console/*=worker02;use_server_errors=400
    /web-console/css/*=worker01
    
    # Example of exclusion from mapping, logo.gif won't be displayed
    # !/web-console/images/logo.gif=*
    
    # Requests to /app-01 or /app-01/something will be routed to worker01
    /app-01|/*=worker01
    
    # Requests to /app-02 or /app-02/something will be routed to worker02
    /app-02|/*=worker02
  4. 创建 workers.properties 文件。

    Worker .properties 文件包含 worker 标签和服务器实例之间的映射定义。此文件遵循用于 Apache mod_jk 工作程序属性 配置的同一文件的语法。

    以下是 workers.properties 文件的示例 :工作程序名称( worker01worker02 )必须与 JBoss EAP undertow 子系统中配置的 instance-id 相匹配。

    将此文件放入 C:\connectors\ 目录中。

    # An entry that lists all the workers defined
    worker.list=worker01, worker02
    
    # Entries that define the host and port associated with these workers
    
    # First JBoss EAP server definition, port 8009 is standard port for AJP in EAP
    worker.worker01.host=127.0.0.1
    worker.worker01.port=8009
    worker.worker01.type=ajp13
    
    # Second JBoss EAP server definition
    worker.worker02.host=127.0.0.100
    worker.worker02.port=8009
    worker.worker02.type=ajp13
  5. 创建 rewrite.properties 文件。

    rewrite.properties 文件包含为特定应用重写规则的简单 URL。重写路径使用名称值对来指定,如下例所示。将此文件放入 C:\connectors\ 目录中。

    #Simple example
    # Images are accessible under abc path
    /app-01/abc/=/app-01/images/
  6. 使用 net stop 和 net start 命令重新启动 IIS 服务器。

    C:\> net stop was /Y
    C:\> net start w3svc

IIS 服务器配置为根据特定应用将客户端请求发送到您配置的特定 JBoss EAP 服务器。

24.9.3. 配置 ISAPI Connector to Balance Client Requests Across 多 JBoss EAP 服务器

此配置在您指定的 JBoss EAP 服务器之间平衡客户端请求。此配置在 IIS 服务器上完成,并且假定您已将 JBoss EAP 配置为 接受来自外部 Web 服务器的请求。您还需要对 IIS 服务器的完整管理员访问权限,并将 IIS 配置为使用 ISAPI 连接器

在客户端请求多个服务器之间取得平衡
  1. 创建用于存储日志、属性文件和锁定文件的目录。

    此流程的其余部分假定您为此使用了目录 C:\connectors\。如果您使用不同的目录,请相应地修改说明。

  2. 创建 isapi_redirect.properties 文件。

    创建名为 C:\connectors\isapi_redirect.properties 的新文件。将以下内容复制到 文件。

    # Configuration file for the ISAPI Connector
    # Extension uri definition
    extension_uri=/jboss/isapi_redirect.dll
    
    # Full path to the log file for the ISAPI Connector
    log_file=c:\connectors\isapi_redirect.log
    
    # Log level (debug, info, warn, error or trace)
    log_level=info
    
    # Full path to the workers.properties file
    worker_file=c:\connectors\workers.properties
    
    # Full path to the uriworkermap.properties file
    worker_mount_file=c:\connectors\uriworkermap.properties
    
    #OPTIONAL: Full path to the rewrite.properties file
    rewrite_rule_file=c:\connectors\rewrite.properties

    如果您不想使用 rewrite.properties 文件,请在行首加上 # 字符来注释掉最后一行。

  3. 创建 uriworkermap.properties 文件。

    uriworkermap.properties 文件包含已部署应用程序 URL 之间的映射,以及哪个 worker 处理向它们的请求。以下示例文件显示了 文件的语法,以及负载均衡配置。通配符(*)字符将各种 URL 子目录的所有请求发送到名为 router 的负载均衡器。下一步中介绍了负载平衡器的配置。

    将您的 uriworkermap.properties 文件放在 C:\connectors\ 中。

    # images, css files, path /status and /web-console will be
    # provided by nodes defined in the load-balancer called "router"
    /css/*=router
    /images/*=router
    /status=router
    /web-console|/*=router
    
    # Example of exclusion from mapping, logo.gif won't be displayed
    # !/web-console/images/logo.gif=*
    
    # Requests to /app-01 and /app-02 will be routed to nodes defined
    # in the load-balancer called "router"
    /app-01|/*=router
    /app-02|/*=router
    
    # mapping for management console, nodes in cluster can be enabled or disabled here
    /jkmanager|/*=status
  4. 创建 workers.properties 文件。

    Worker .properties 文件包含 worker 标签和服务器实例之间的映射定义。此文件遵循用于 Apache mod_jk 工作程序属性 配置的同一文件的语法。

    以下是 workers.properties 文件的示例 :负载均衡器在文件的末尾配置,组成 worker worker01worker02。这些工作程序名称必须与 JBoss EAP undertow 子系统中配置的 instance-id 相匹配。

    将此文件放入 C:\connectors\ 目录中。

    # The advanced router LB worker
    worker.list=router,status
    
    # First EAP server definition, port 8009 is standard port for AJP in EAP
    #
    # lbfactor defines how much the worker will be used.
    # The higher the number, the more requests are served
    # lbfactor is useful when one machine is more powerful
    # ping_mode=A – all possible probes will be used to determine that
    # connections are still working
    
    worker.worker01.port=8009
    worker.worker01.host=127.0.0.1
    worker.worker01.type=ajp13
    worker.worker01.ping_mode=A
    worker.worker01.socket_timeout=10
    worker.worker01.lbfactor=3
    
    # Second EAP server definition
    worker.worker02.port=8009
    worker.worker02.host=127.0.0.100
    worker.worker02.type=ajp13
    worker.worker02.ping_mode=A
    worker.worker02.socket_timeout=10
    worker.worker02.lbfactor=1
    
    # Define the LB worker
    worker.router.type=lb
    worker.router.balance_workers=worker01,worker02
    
    # Define the status worker for jkmanager
    worker.status.type=status

  5. 创建 rewrite.properties 文件。

    rewrite.properties 文件包含为特定应用重写规则的简单 URL。重写路径使用名称值对来指定,如下例所示。将此文件放入 C:\connectors\ 目录中。

    #Simple example
    # Images are accessible under abc path
    /app-01/abc/=/app-01/images/
    Restart the IIS server.
    
    Restart your IIS server by using the net stop and net start commands.
    C:\> net stop was /Y
    C:\> net start w3svc

IIS 服务器配置为将客户端请求发送到 workers.properties 文件中引用的 JBoss EAP 服务器,以 1:3 比例在服务器之间分散负载。这一比例派生自分配给每台服务器的负载平衡因子( lbfactor )。