下面以5.x为例
JBoss的配置
1 web服务端口号的修改
这点在前文中有所提及,即修改JBoss安装目录"server"default"deploy"jboss-web.deployer下的server.xml文件,内容如下:
<Connectorport="8080"address="${jboss.bind.address}"maxThreads="250"
maxHttpHeaderSize="8192"emptySessionPath="true"protocol="HTTP/1.1"
enableLookups="false"redirectPort="8443"acceptCount="100"
connectionTimeout="20000"disableUploadTimeout="true"/>
将上面的8080端口修改为你想要的端口即可。重新启动JBoss后访问:http://localhost/:新设置的端口,可看到JBoss的欢迎界面。
2 JBoss的安全设置
(1)jmx-console登陆的用户名和密码设置
在%JBOSS_HOME%/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml文件中
将注释文档去掉修改为:
<jboss-web>
<security-domain>java:/jaas/jmx-console< /security-domain>
< /jboss-web>
在同目录下web.xml,查找< security-constraint/>节点,修改为:
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor< /web-resource-name>
<description>An example security config that only allows user with the role
JBossAdmin to access the HTML JMX console web application
< /description>
<url-pattern>/*< /url-pattern>
<http-method>GET< /http-method>
<http-method>POST< /http-method>
< /web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin< /role-name>
< /auth-constraint>
< /security-constraint>
在jmx-console安全域和运行角色JBossAdmin都是在login-config.xml中配置,在%JBOSS_HOME%/server/default/conf下找到它,查找application-policy name = "jmx-console",修改为
<application-policyname = "jmx-console">
<authentication>
<login-modulecode="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-optionname="usersProperties">props/jmx-console-users.properties
< /module-option>
<module-optionname="rolesProperties">props/jmx-console-roles.properties
< /module-option>
< /login-module>
< /authentication>
< /application-policy>
在此处可以看出,登录的角色、用户等的信息分别在props目录下的jmx-console-roles.properties和jmx-console-users.properties文件中设置,分别打开这两个文件。
其中jmx-console-users.properties文件的内容如下:
# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
该文件定义的格式为:用户名=密码,在该文件中,默认定义了一个用户名为admin,密码也为admin的用户,读者可将其改成所需的用户名和密码。
jmx-console-roles.properties的内容如下:
# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin, HttpInvoker
该文件定义的格式为:用户名=角色,多个角色以“,”隔开,该文件默认为admin用户定义了JBossAdmin和HttpInvoker这两个角色。
配置完成后读者可以通过访问: http://localhost:8088/jmx-console/ ,输入jmx-console-roles.properties文件中定义的用户名和密码,访问jmx-console的页面。
(2)web-console登陆的用户名和密码设置
找到%JBOSS_HOME%/server/default/deploy/management/console-mgr.sar/web-console.war/WEB-INF下的jboss-web.xml文件,去掉< security-domain>java:/jaas/web-console< /security-domain>的注释。
在同目录下的web.xml文件中去掉< security-constraint>部分的注释。
在%JBOSS_HOME%/server/default/conf下的login-config.xml文件中查找application-policy name = "web-console"
在文件中可以看到,设置登录web-console的用户名和角色等信息分别在login-config.xml文件所在目录下的web-console-users.properties和web-console- roles.properties文件中,但因为该目录下无这两个文件,我们在JBoss安装目录"server"default"conf"props目录下建立这两个文件,文件内容可参考在“jmx-console登录的用户名和密码设置”中的两个相应的配置文件的内容。
web-console-users.properties文件的内容如下:
# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
web-console-roles.properties文件的内容如下:
admin=JBossAdmin,HttpInvoker
因为此时这两个文件不与login-config.xml同目录,所以login-config.xml文件需进行少许修改
<module-optionname="usersProperties">props/web-console-users.properties
< /module-option>
<module-optionname="rolesProperties">props/web-console-roles.properties
< /module-option>
JBoss的配置就完成了。
本文出自 “myswallow fly on the sky” 博客,请务必保留此出处http://7915791.blog.51cto.com/7905791/1359744
原文:http://7915791.blog.51cto.com/7905791/1359744