JBoss 只能本機 localhost:8080 連接但其他電腦無法顯示網頁
下載 JBoss 4.2.0.GA 安裝啟動後本機可以用 http://localhost:8080 或是 [url]http://127.0.0.1:8080[/url] 顯示網頁。
但是使用 [url]http://xxx.xxx.xxx.xxx:8080[/url] 主機 IP 或網址的方式都無法顯示網頁
其他電腦連接也都是無法顯示網頁 這是 JBoss-4.2.0.GA 的 jboss.bind.address 預設值的問題
連入 http://localhost:8080/ 檢視 JBoss Web Console 檢查 system 內容發現 jboss.bind.address 被指定為 127.0.0.1 的 IP 值,所以只會回應連接 127.0.0.1 的請求。
因為我是新手所以還不太了解 *.xml 的設定方式,所以不知道可以設定在哪個檔案以及設定的格式。
不過可以先用 run.bat / run.sh 指定參數的方式解決
只要加上 -b 0.0.0.0 可以了參考如下
[code]%JBOSS_HOME%\bin>run.bat -b 0.0.0.0[/code]
這樣 JBoss 主機不管有多少 IP 都會監聽回應了。 若要知道 run.bat /run.sh 還有哪些參數可以用可以用 -h 來查看[code]
C:\jboss-4.2.3.GA\bin>run.bat -h
===============================================================================
JBoss Bootstrap Environment
JBOSS_HOME: C:\jboss-4.2.3.GA
JAVA: C:\Program Files\Java\jdk1.6.0_29\bin\java
JAVA_OPTS: -Dprogram.name=run.bat -server -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.ser
ver.gcInterval=3600000
CLASSPATH: C:\Program Files\Java\jdk1.6.0_29\lib\tools.jar;C:\jboss-4.2.3.GA\bin\run.
jar
===============================================================================
usage: run.bat [options]
options:
-h, --help Show this help message
-V, --version Show version information
-- Stop processing options
-D<name>[=<value>] Set a system property
-d, --bootdir=<dir> Set the boot patch directory; Must be absolute or url
-p, --patchdir=<dir> Set the patch directory; Must be absolute or url
-n, --netboot=<url> Boot from net with the given url as base
-c, --configuration=<name> Set the server configuration name
-B, --bootlib=<filename> Add an extra library to the front bootclasspath
-L, --library=<filename> Add an extra library to the loaders classpath
-C, --classpath=<url> Add an extra url to the loaders classpath
-P, --properties=<url> Load system properties from the given url
-b, --host=<host or ip> Bind address for all JBoss services
-g, --partition=<name> HA Partition name (default=DefaultDomain)
-u, --udp=<ip> UDP multicast address
-l, --log=<log4j|jdk> Specify the logger plugin type
請按任意鍵繼續 . . .
C:\jboss-4.2.3.GA\bin>
[/code] 在 run.bar -b 0.0.0.0 的目的就是將 JBoss 的 jboss.bind.address 屬性指定為 0.0.0.0
這樣在啟動載入各項 xml 設定檔時,就會將 ${jboss.bind.address} 代入 0.0.0.0
所以可以透過直接修改 xml 內的設定解決
jboss-4.0.5.GA\server\default\deploy\jbossweb-tomcat55.sar\server.xml
找到下列內容[code]
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
[/code]修改成[code]
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector port="8080" address="0.0.0.0"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
[/code]另一個 JBoss 版本
jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\server.xml
找到下列內容[code]
<Connector port="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" />
[/code]將其修改成[code]
<Connector port="8080" address="0.0.0.0"
maxThreads="250" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
[/code]這樣就會讓 8080 埠接收所有連線
雖然處理上有些繁瑣,不過,因為 ${jboss.bind.address} 在很多設定位置都有用到,所以啟動時在 run.bat 指定 -b 是全面性的影響,也就是將所有服務都對外打開了門,這樣的處理方式必然是提高資安風險。
頁:
[1]