|
|
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已! |
|
恭喜您是本站第 1673643
位訪客!
登入 | 註冊
|
|
|
|
發表者 |
討論內容 |
冷日 (冷日) |
發表時間:2016/9/16 8:46 |
- Webmaster
- 註冊日: 2008/2/19
- 來自:
- 發表數: 15771
|
- [轉貼]Tomcat listen only on localhost
- Tomcat listen only on localhost
We want to run servlets on Tomcat and serve them via Apache using the proxy_ajp connector.
On the standard installation, Tomcat was listening on port 8080, which was not blocked by a firewall. This means a servlet was not only accessible via Apache on port 80:
http://www.example.com/servlet
But also via Tomcat on port 8080:
http://www.example.com:8080/servlet
To ensure the only way in to our servlets is via apache, you can try the following fix: In the Tomcat server.xml add the attribute ‘address=”127.0.0.1″‘ to the HTTP and AJP connectors. This makes Tomcat listen only on the localhost.
Examples:
<Connector address="127.0.0.1" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector address="127.0.0.1" port="8009" protocol="AJP/1.3" redirectPort="8443" />
Then in your apache config, ensure that your proxy_ajp is connecting on localhost.
ProxyPass /my_servlet ajp://localhost:8009/my_servlet
ProxyPassReverse /my_servlet ajp://localhost:8009/my_servlet
冷日: 先上這個範例,他是教你如何讓 Tomcat 只 Listen localhost! 因為他要讓前端交給 Apache 來處理,畢竟大多數時候我們還是比較信任 Apache 及 80 Port! 原文出處: Tomcat listen only on localhost » Computational Geoscience Rant
|
|
冷日 (冷日) |
發表時間:2016/9/16 8:50 |
- Webmaster
- 註冊日: 2008/2/19
- 來自:
- 發表數: 15771
|
- [轉貼]Can't access Tomcat using IP address
- 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
<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
|
|
|
冷日 (冷日) |
發表時間:2016/9/16 8:53 |
- Webmaster
- 註冊日: 2008/2/19
- 來自:
- 發表數: 15771
|
- [轉貼]Can only connect to Apache Tomcat with localhost
- Can only connect to Apache Tomcat with localhost
I can access my web application by going to http://localhost:8080/webapp, however, I cannot access it by using my local IP address. As far as I know, I am using default configuration options. This is also on Windows Server 2008 R2 and there is no firewall currently running. Thanks. Here is a link to the server.xml file: http://codeviewer.org/view/code:1dad
I added address="[IP ADDRESS HERE]" within the connector tag in the server.xml file, and it now works properly.
冷日: 這也是一樣的問題,基本上就是至少要加上
address="[IP ADDRESS HERE]"
這樣才行! 或是加上 在不然還有一招 原文出處:windows server 2008 r2 - Can only connect to Apache Tomcat with localhost - Server Fault
|
|
|