第 2 章 保护服务器及其接口
2.1. 构建块 复制链接链接已复制到粘贴板!
2.1.1. 接口和套接字绑定 复制链接链接已复制到粘贴板!
JBoss EAP 使用其主机的接口(如 inet-address、nic 等)以及用于 Web 应用程序及其管理界面的通信端口。这些接口和端口通过 JBoss EAP 配置文件中的 interfaces 和 socket-binding-groups 设置(如 standalone.xml、domain.xml、host.xml 等)定义和配置。
有关如何定义和配置 interfaces 和 socket-binding-groups 的更多信息,请参阅 配置指南中的套接字绑定部分。
接口示例
<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
</interfaces>
Socket Binding Group 示例
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
<socket-binding name="http" port="${jboss.http.port:8080}"/>
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="txn-recovery-environment" port="4712"/>
<socket-binding name="txn-status-manager" port="4713"/>
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
</socket-binding-group>
2.1.2. Security Realms 复制链接链接已复制到粘贴板!
JBoss EAP 使用安全域来定义身份验证和授权机制(如本地、LDAP 和属性等),然后供管理接口使用。有关安全域的更多信息,请参阅 Red Hat JBoss Enterprise Application Platform 安全架构指南中的 Security Realms 部分。
Security Realms 示例
<security-realms>
<security-realm name="ManagementRealm">
<authentication>
<local default-user="$local" skip-group-loading="true"/>
<properties path="mgmt-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization map-groups-to-roles="false">
<properties path="mgmt-groups.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
<security-realm name="ApplicationRealm">
<authentication>
<local default-user="$local" allowed-users="*" skip-group-loading="true"/>
<properties path="application-users.properties" relative-to="jboss.server.config.dir"/>
</authentication>
<authorization>
<properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
</authorization>
</security-realm>
</security-realms>
除了更新现有的安全域外,JBoss EAP 还允许您创建新的安全域。您可以通过管理控制台以及从管理 CLI 调用以下命令来创建新的安全域:
/core-service=management/security-realm=NEW-REALM-NAME:add()
如果您创建新的安全域并希望使用属性文件进行身份验证或授权,则必须为新的安全域创建新的属性文件。JBoss EAP 不重复使用其他安全域使用的现有文件,也不会自动创建新的配置中指定的新文件(如果它们不存在)。
2.1.3. 使用安全域和套接字绑定来保护管理接口 复制链接链接已复制到粘贴板!
默认情况下,JBoss EAP 定义了一个 http-interface 来连接管理界面。此接口在 JBoss EAP 配置的 <management-interfaces > 部分中定义:
<management-interfaces>
<http-interface security-realm="ManagementRealm" http-upgrade-enabled="true">
<socket-binding http="management-http"/>
</http-interface>
</management-interfaces>
请注意,接口指定了 security-realm 和 socket-binding。更新指定安全域和套接字绑定的配置允许以不同的方式保护管理接口。除了能够通过安全域和套接字绑定保护每个接口外,这两个接口也可以完全禁用,并且这些接口的用户可以配置为具有各种角色和访问权限。本指南中也有一些主题,如安全审计、安全密码和 JMX,它们与其他 JBoss EAP 中的其他子系统重叠,但仍然与保护 JBoss EAP 相关。