JBoss7配置指南(三)

來源:互聯網
上載者:User

4.管理工作

4.1 網路介面和連接埠

4.1.1 網路介面聲明

JBoss AS 7 在整個設定檔中都引用命名的介面。一個網路介面通過指定一個邏輯名和選擇一個物理介面來聲明。
[standalone@localhost:9999 /] :read-children-names(child-type=interface)
{
   "outcome" => "success",
   "result" => [
       "management",
       "public"
   ]
}
以上操作意味著server聲明了兩個介面:一個可以使用”management”進行引用,另外一個可以用”public”引用。管理層(比如HTTP管理點)需要用到的所有組件和服務都可以使用”management”介面。與網路通訊有關的應用(如Web, Message等等)都可以使用”public”介面.介面的名字沒有任何特別的要求;可以用任何名字聲明介面。配置的其他部分可以用邏輯名來引用這些介面,而不用包含介面的所有詳細資料(在管理域裡伺服器上的這些資訊隨著機器不同而不同).
domain.xml, host.xml 和standalone.xml 都包含聲明介面的部分。但我們看這些在xml檔案中介面聲明時,就會發現介面的選擇條件(selection criteria)。介面選擇的條件有兩種類型:一種是單獨的xml元素,介面綁定到萬用字元地址;另外一種是介面或者地址有一個或者多個特徵值需要滿足。下面是一個介面條件選擇的例子,每個介面都有特定的IP地址:
<interfaces>
  <interface name="management">
   <inet-address value="127.0.0.1"/>
  </interface>
  <interface name="public">
   <inet-address value="127.0.0.1"/>
  </interface>
</interfaces>
另外一些使用萬用字元的例子:
<interface name="global">
   <!-- 使用任何地址 -->
   <any-address/>
</interface>

<interface name="ipv4-global">
   <!--使用任何IPV4的例子-->
   <any-ipv4-address/>
</interface>

<interface name="ipv6-global">
   <!-- 使用任何IPV6的例子 -->
   <any-ipv6-address/>
</interface>

<interface name="external">
   <nic name="eth0"/>
</interface>

<interface name="default">
   <!-- 匹配下面子網地址,而且支援multicats不是點對點的地址-->
   <subnet-match value="192.168.0.0/16"/>
   <up/>
   <multicast/>
   <not>
      <point-to-point/>
   </not>
</interface>

4.1.2 Socket Binding Groups

AS7中socket的配置類似於interface的聲明,Sockets用一個邏輯名來聲明,可以在整個配置中引用。 多個Sockets聲明可以用一個特定的名字聲明成為一個組。這樣在配置一個在管理域裡的server group時可以方便的引用一個特定的socket binding group. Socket binding group通過interface邏輯名來引用interface:
<socket-binding-group name="standard-sockets" default-interface="public">
   <socket-binding name="jndi" port="1099"/>
   <socket-binding name="jmx-connector-registry" port="1090"/>
   <socket-binding name="jmx-connector-server" port="1091"/>
   <socket-binding name="http" port="8080"/>
   <socket-binding name="https" port="8443"/>
   <socket-binding name="jacorb" port="3528"/>
   <socket-binding name="jacorb-ssl" port="3529"/>
   <socket-binding name="osgi-http" port="8090"/>
   <socket-binding name="remoting" port="4447"/>
   <socket-binding name="txn-recovery-environment" port="4712"/>
   <socket-binding name="txn-status-manager" port="4713"/>
   <socket-binding name="messaging" port="5445"/>
   <socket-binding name="messaging-throughput" port="5455"/>
</socket-binding-group>
一個socket binding 包含一下資訊:

  • name – socket配置的邏輯名,可以在配置的其他任何地方引用。
  • port –  這個配置中socket要綁定到的基礎連接埠 (注意server可以通過配置增減所有連接埠值來覆蓋這一配置)
  • interface (可選) – 配置中socket要綁定介面的邏輯名 (參考 上面的介面聲明 ) .如果沒有指定, socket binding group 配置元素中的default-interface屬性值將會被使用。
  • multicast-address (可選) --如果socket用於多播,將會使用這個多播地址。
  • multicast-port (可選) –  如果socket用於多播,將會使用這個多播連接埠
  • fixed-port (可選, 預設是false) – 如果是true,  連接埠值將一直使用這個值,這個值不會被使用增減連接埠值而覆蓋。

4.2 管理介面的安全性

       除了在運行伺服器或者伺服器組上的各種服務,JBoss7還提供了兩個管理介面允許遠端用戶端可以管理JBoss AS7.這個章節中介紹如何使用這些介面,以及如何對這些介面進行加密。
       這兩個管理介面被暴露成一個HTTP介面和一個Native介面。HTTP介面既用來提供基於GWT的管理主控台(admin console)使用,也提供給使用JSON編碼協議和de-typed RPC API各種管理操作使用。當運行在單獨運行伺服器(standalone)時候,Native介面允許管理操作通過私人的二進位協議訪問。這種使用二進位協議類型的操作可以通過AS7提供的命令列工具,也可以通過使用AS7jar檔案的遠程用戶端進行互動。
       在管理域下使用這些介面稍有些負責。在每一個主機上都有一個host controller的進程。在主機上的host controller會配置成為domain controller.在管理域中可以用同樣的方式來使用HTTP介面; HTTP介面允許基於GWT的管理主控台(admin console)運行在主domain controller,也允許任何基於HTTP和JSON的管理控制用戶端在任何host controller上執行管理操作。然而其他的一些用戶端則使用Natvie介面:一旦host controller啟動真正的應用伺服器執行個體,這些應用伺服器則通過native介面與host
controoler後台建立串連;從host controller則使用native 介面與主domain controller在後台建立串連來擷取domain 模型的拷貝,並隨後接收主domain cotroller的操作請求。

 

4.2. 1初始化設定

單獨運行伺服器的介面配置在standalone.xml裡定義,在管理域裡運行伺服器的介面配置在host.xml 中。在兩個檔案種,介面配置都有相同的結構:
<management>      
   ...
   <management-interfaces>         
      <native-interface interface="management" port="9999" />         
      <http-interface interface="management" port="9990"/>      
   </management-interfaces>  
</management>
...
<interfaces>
   <interface name="management">
      <inet-address value="127.0.0.1"/>
   </interface>
   <interface name="public">
      <inet-address value="127.0.0.1"/>
   </interface>
</interfaces>
navtive介面預設監聽9999連接埠,http介面監聽9990.管理介面同時與一個命名為 “management”的網路介面(network inteface)相關聯。雖然management網路介面(network interface)的配置和public 網路介面的預設配置相同,但我們推薦不要合并這兩個配置。managment和public的網路介面分開配置可以保證任何將應用伺服器中服務更為公開的配置更改,不會無意識的公開本不需要公開的管理介面。

 

4.2.2 快速配置

在本章節剩下的部分我們講更為詳細的講述安全域的配置-但是如果你想快速的啟用安全域並且完善安全配置來滿足需求,預設的配置包含一個預先定義的安全域,它基於一個property檔案和一個可以通過命令列來啟用的指令碼。
安全域定義在standalone.xml或者host.xml檔案中<management>元素. 預設的安全域:
<management>
   <security-realms>
      <security-realm name="PropertiesMgmtSecurityRealm">
         <authentication>
            <properties path="mgmt-users.properties" relative-to="jboss.server.config.dir" />
         </authentication>
      </security-realm>
   </security-realms>
   ...      
</management>
預設安全域通過調用在configuratiion目錄下的mgmt-user.properties來校正串連的使用者。property檔案預設沒有任何使用者,因此新的使用者要用username=password格式添加到檔案中:
手動啟用兩個介面配置好的管理域:
<management>
   ...
   <management-interfaces>
      <native-interface interface="management" port="9999" security-realm="PropertiesMgmtSecurityRealm" />
      <http-interface interface="management" port="9990" security-realm="PropertiesMgmtSecurityRealm"/>
   </management-interfaces>
</management>
這將為Http interface啟用Http Digest authentication,並且在Native interface啟用Digest SASL-這也意味著對於原始密碼不會在用戶端和伺服器端進行傳輸驗證。
使用指令碼來啟用安全域,首先要編輯“mgmt-users.properties”,因為配置會馬上生效。你需要至少定義一個使用者,並且執行以下命令:
對於單獨啟動並執行伺服器:
./jboss-admin.sh --connect --file=scripts/secure-standalone-mgmt.cli
對於在管理域的伺服器:
./jboss-admin.sh --connect --file=scripts/secure-host-controller-mgmt.cli
注意這個指令碼只能運行在預設配置為master的host上。如果建立了其他具有不同名稱的host,那麼需要更新這個指令碼或者手動對這個新的配置實施安全性。並且還要注意,這個指令碼僅僅改變它要啟動並執行名為master的host,如果有多個host controller,這個指令碼需要使用他們所有正確的host名字運行去更改。同時,請閱讀這個章節的其他部分關於如何配置從host controller串連主host controller的校正。
 

禁用JMX遠端存取
除了以上的JBoss管理協議,還有允許JDK和應用管理操作的遠程JMX 串連。為了安全性,可以通過刪除遠端連線配置來禁止這一服務,或者刪除整個subsystem.
<subsystem xmlns="urn:jboss:domain:jmx:1.0">
     <!-- Delete the following line to disable remote access -->
     <jmx-connector registry-binding="jmx-connector-registry" server-binding="jmx-connector-server" />
</subsystem>

4.2.3 詳細配置

管理介面的配置在<management>下的三個節點中:
<management>
   <security-realms />
   <outbound-connections />
   <management-interfaces />
</management>
<security-realms /> -  配置一個或者多個安全域來定義遠端使用者如何串連到伺服器進行驗證,並且定義伺服器上的身份(identity)。
<outbound-connections /> -有時候安全域的配置需要串連到一個外部的資源;這些串連在這裡配置。
<management-interfaces /> - 這裡定義Http interface和Native interface,正如我們在簡介裡描述的那樣。

4.2.3.1 管理介面

對於單個管理介面的配置是最簡單的。僅僅需要組態管理介面的”security-realm”屬性,來指定使用安全域的名字。因為管理介面啟動安全域時,要查詢安全域所提供的功能,並且啟動安全相依的傳輸:比如使用者的密碼如果可以從安全域中獲得,Http interface會嘗試使用Digest驗證,如果使用者密碼不能從安全域中擷取,http interface會轉而支援Basic驗證。
<management>   ...
   <management-interfaces>
      <native-interface ... security-realm="PropertiesMgmtSecurityRealm" />
      <http-interface   ... security-realm="PropertiesMgmtSecurityRealm"/>
   </management-interfaces>
</management>
管理介面可以使用同樣的安全域,但這不是必須的。如果需要,不同的管理介面可以使用不同的安全域。

4.2.3.2 安全域

<security-realms /> 元素用來配置一個或者多個安全域。安全域的配置具有以下結構:
<management>
   <security-realms>
      <security-realm name="SampleRealm">
         <server-identities />
         <authentication />
      </security-realm>
   </security-realms>
   ...
</management>
<server-identities />元素定義server的身份資訊。目前可以配置一個SSL身份(identity)來定義伺服器如何從一個keystore 取得身份資訊。也可以配置一個加密的身份-伺服器使用什麼樣的命令或密碼和其他的伺服器進行通訊。
<authentication /> 定義如何驗證串連到伺服器的使用者.

4.2.3.2.1 Authentication(驗證)

最初,AS7支援三種機制來驗證串連到伺服器的使用者:
LDAP – 使用LDAP 伺服器來驗證使用者的額身份資訊。
Users – 定義在domain model裡的使用者名稱和密碼資訊,這僅作為簡單測試使用。
Properties – 使用者名稱和密碼定義在一個伺服器安裝檔案目錄的 property檔案中。
下表概括了管理介面支援的驗證機制,用來對終端使用者在傳輸層級上進行驗證:

Authentication
Mechanism

HTTP
Interface
Native
Interface
LDAP HTTP BASIC Not Supported1
Users HTTP DIGEST SASL DIGEST
Properties HTTP DIGEST SASL DIGEST

 

 

1 – 將被增加到AS7-1167
HTTP Basic和SASL Plain(實現以後)在一個表單裡傳輸使用者密碼,很容易被破解。
下面的章節闡述如何配置這些驗證機制:

 

4.2.3.2.1 . 1 LDAP

 

LDAP驗證操作首先要建立一個和遠程目錄伺服器的串連。然後使用使用者提通的使用者名稱去執行尋找區別使用者的識別名(distinguished name)。最後驗證器和目錄伺服器建立一個新的串連,使用尋找到的識別名和使用者提供的密碼來驗證是否是合法使用者。
這是一個使用LDAP驗證的安全網域設定:
<security-realm name="TestRealm">
   <authentication>
      <ldap connection="ldap_connection" base-dn="CN=Users,DC=mydomain,DC=aslab" username-attribute="sAMAccountName"  />
   </authentication>
</security-realm>
ldap元素可以配置以下屬性:
connection - 定義在 <outbound-connections>的串連來串連到LDAP目錄伺服器。
base-dn - 開始搜尋使用者的上下文中的識別名(基準識別名).
Username-attribute – 目錄中的使用者名稱的屬性,用來匹配提供的使用者名稱
recursive (default - false) - 是否需要迭代尋找
user-dn (default - dn) - 使用者中存放識別名的屬性, 用來校正使用者資訊

 

4.2.3.2.1 . 2   User

 

User校正器是一個對儲存在domain model裡使用者名稱和密碼進行驗證的簡單校正器。校正器僅用作簡單的測試使用:
這是一個使用User驗證器的例子:
<security-realm name="TestRealm">
   <authentication>
      <users>
         <user username="TestUser">
            <password>TestUserPassword</password>
         </user>
      </users>
   </authentication>
</security-realm>
在這個配置中,每個使用者都用<user>進行定義,使用者名稱使用”username” 屬性定義,password定義在user下的<password>中。

 

4.2.3.2.1 . 3 Properties

 

Properties校正器和User校正器類似,除了使用者名稱和密碼定義在一個properties檔案中。比起 User校正的優點是password不必在domain model中暴露。
這是一個使用properties驗證器配置安全域的一個例子:
<security-realm name="TestRealm">
   <authentication>
      <properties path="users.properties" relative-to="jboss.server.config.dir" />
   </authentication>
</security-realm>
Properties檔案通過簡單定義”path”屬性來指定檔案的路徑和 ”relative-to”屬性來引用定義好的路徑和path屬性相對的路徑。在這個例子中,user.properties在存放stadnalone.xml檔案相同的目錄下。 如果”relateive-to”屬性沒有指定,那麼path屬性的之必須是一個絕對路徑。

 

4.2.3.2.2 Server Identities(伺服器身份)

 

<server-identities>用於配置在多種情境中伺服器辨別自己身份的資訊。 目前在HTTP interface中可以定義一個SSL indentiy並且使用這一indentity來啟用SSL,另外一個Secret identity可以存放一個密碼,當host controller和遠端domain controller 建立串連時,使用這一個定義好的Secret indentity.

  • SLL

SSL identity的配置目前需要從本地檔案系統中載入一個靜態keystore.以後會增強這一個功能來允許多種類型的keystore:
一個SSL indentity的配置樣本如下:
<security-realm name="TestRealm">
   <server-identities>
      <ssl>
         <keystore path="server.keystore" relative-to="jboss.server.config.dir" password="keystore_password" />
      </ssl>
   </server-identities>
</security-realm>
keystore的路徑資訊和properites驗證器中properties檔案資訊相同,使用一個路徑指定keystore和一個可選的relative-to 屬性來指定path屬性相對於一個已知的路徑。

  • Secret

從domain controller串連到一個加密的主domain controller時,需要配置Secret identity.
為了實現串連加密的主domain controoler,下面是在從domain controller中增加的配置:

<host xmlns="urn:jboss:domain:1.0"
      name="slave">

   <management>
      <security-realms>
         <security-realm name="TestRealm">
            <server-identities>
               <secret value="c2xhdmVfcGFzc3dvcmQ=" />
            </server-identities>
         </security-realm>
       </security-realms>
       ...
    </management>

    <domain-controller>
       <remote host="127.0.0.1" port="9999" security-realm="TestRealm" />
    </domain-controller>

    ...
</host>
這裡<remote>定義了domain controller引用了一個定義好的安全域。,這個引用意味著這個安全域會被用來載入用戶端的配置(以後這將會擴充使得域也同樣可以為用戶端的串連定義SSL)
secret是密碼採用Base64編碼,串連會使用host名(在這個樣本中是'slave')和從secret中得到的密碼進行驗證。
AS7-1102列出了密碼的處理將會被增強,來更好的保護密碼的配置。如採用密碼混淆,加密方式以及使用外部的security provider, smart card或者使用 PKCS#11的硬體加密模組。

4.2.3.3 Outbound connections(外部串連)

如前面所述,外部串連用來串連一個遠端伺服器,目前僅支援LDAP串連,以後會增加資料庫連接來支援對儲存在資料庫中的資訊進行驗證。

  • LDAP

下面是一個串連LDAP伺服器的例子:
<outbound-connections>
   <ldap name="ldap_connection" url="ldap://127.0.0.1" search-dn="CN=AS7 Test Server,CN=Users,DC=mydomain,DC=aslab" search-credential="AS_Password" />
</outboundconnections>
<ladp>可以配置以下屬性:
name - 串連名,ladp驗證其會使用這個名字來引用這個串連。
url – 串連目錄伺服器的URL.
search-dn - 使用者初始化搜尋的識別名
search-credential – 串連進行搜尋的密碼
initial-context-factory (default - com.sun.jndi.ldap.LdapCtxFactory) -用來建立串連的 initial context factory 

 

4.2.4 問題:

Application server如何串連到host controller的native interface上-是如何進行驗證的? 
當JBossAS7進程啟動時會建立一個隨機的key並且將這個key傳輸到啟動的伺服器執行個體,applicaiotn server使用這個key來驗證native interface的串連。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.