對這文章發表回應
發表限制: 非會員 可以發表
發表者: 冷日 發表時間: 2016/9/16 8:50:27
Can't access Tomcat using IP address
I'm running a Tomcat 5.5 instance (port: 8089) on Windows 7.
The server runs correctly if I open http://localhost:8089/ but it gives me an error (Connection refused) on http://192.168.1.100:8089/
I thought it was a firewall issue...so I disabled it, but I still have no luck.
Thanks in advance.
SOLVED:
added address="0.0.0.0" to Connector string, it works! thanks a lot!
You need to make Tomcat listen to 192.168.1.100 address also.
If you want it to listen to all interfaces (IP-s) just remove "address=" from Connector string in your configuration file and restart Tomcat.
Or just use your IP to listen to that address address=192.168.1.100 in the Connector string
You need allow ip based access for tomcat in server.xml, by default its disabled. Open server.xml search for
Here add a new attribute useIPVHosts="true" so it looks like this,
New versions of application servers removed the ability of binding to your entire network interface and limited it just to the local interface (localhost). The reason being was for security. From what I know, Tomcat and JBoss implement the same security measures.
If you want to bind it to another IP you can explicitly set it in your connector string:
Tomcat: address="192.168.1.100"
JBoss: you pass in a -b 192.168.1.100 as a command line.
Just remember that binding 0.0.0.0 allows anyone access to your box to access that server. It will bind to all addresses. If that is what you want, then use 0.0.0.0, if it isn't then specify the address you would like to explicitly bind instead.
Just make sure you understand the consequences binding to all addresses (0.0.0.0)
If you are trying to access your web app which is running on apache tomcat server, it might be working perfect while you are trying to use it on http://localhost:8080/ , it will not work same if you are trying to access it on your mobile device browser for ex. chrome using http://192.168.x.x:8080/ so if you want to access via ip address on your remote/mobile device , do following settings
Open server.xml file.
Change
to.
Save the file
Stop and restart the server
Now access on your mobile device using ip address http://192.168.1.X:8080/
冷日:
但事實上是,新版本的 Application server『預設只能 Localhost』!
所以,若我們要讓 Tomcat 可以透過 IP 服務的話,是要修改 server.xml 低!
原文出處:windows 7 - Can't access Tomcat using IP address - Stack Overflow
I'm running a Tomcat 5.5 instance (port: 8089) on Windows 7.
The server runs correctly if I open http://localhost:8089/ but it gives me an error (Connection refused) on http://192.168.1.100:8089/
I thought it was a firewall issue...so I disabled it, but I still have no luck.
Thanks in advance.
SOLVED:
added address="0.0.0.0" to Connector string, it works! thanks a lot!
You need to make Tomcat listen to 192.168.1.100 address also.
If you want it to listen to all interfaces (IP-s) just remove "address=" from Connector string in your configuration file and restart Tomcat.
Or just use your IP to listen to that address address=192.168.1.100 in the Connector string
You need allow ip based access for tomcat in server.xml, by default its disabled. Open server.xml search for
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
Here add a new attribute useIPVHosts="true" so it looks like this,
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443"
useIPVHosts="true" />
New versions of application servers removed the ability of binding to your entire network interface and limited it just to the local interface (localhost). The reason being was for security. From what I know, Tomcat and JBoss implement the same security measures.
If you want to bind it to another IP you can explicitly set it in your connector string:
Tomcat: address="192.168.1.100"
JBoss: you pass in a -b 192.168.1.100 as a command line.
Just remember that binding 0.0.0.0 allows anyone access to your box to access that server. It will bind to all addresses. If that is what you want, then use 0.0.0.0, if it isn't then specify the address you would like to explicitly bind instead.
Just make sure you understand the consequences binding to all addresses (0.0.0.0)
If you are trying to access your web app which is running on apache tomcat server, it might be working perfect while you are trying to use it on http://localhost:8080/ , it will not work same if you are trying to access it on your mobile device browser for ex. chrome using http://192.168.x.x:8080/ so if you want to access via ip address on your remote/mobile device , do following settings
Open server.xml file.
Change
<Connector connectionTimeout="20000" port="8080"protocol="HTTP/1.1" redirectPort="8443"/>
to.
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" address="0.0.0.0" />
Save the file
Stop and restart the server
Now access on your mobile device using ip address http://192.168.1.X:8080/
冷日:
但事實上是,新版本的 Application server『預設只能 Localhost』!
所以,若我們要讓 Tomcat 可以透過 IP 服務的話,是要修改 server.xml 低!
原文出處:windows 7 - Can't access Tomcat using IP address - Stack Overflow