无法访问远程linux服务器上的tomcat [英] Can't access tomcat on remote linux server

查看:40
本文介绍了无法访问远程linux服务器上的tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 192.168.168.1(子网掩码/24)有一个远程 linux 服务器,它安装并运行了 tomcat.我知道它正在运行,因为当我通过 SSH 连接到它并执行wget localhost:8080"时,我得到:

I have a remote linux server at 192.168.168.1 (subnet mask /24) which has tomcat installed and running. I know it's running because when I SSH to it and do "wget localhost:8080" I get:

Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 200
Length: unspecified [text/html]
Saving to: ‘index.html.1’

    [ <=>                                   ] 11,230      --.-K/s   in 0s

2018-07-05 15:37:21 (184 MB/s) - ‘index.html.1’ saved [11230]

我的本​​地windows机器在同一个网络上,ip地址为192.168.168.2,当我打开浏览器并在url栏中输入192.168.168.1:8080"时,它告诉我一段时间后连接超时.

My local windows machine is on the same network with an ip address of 192.168.168.2, and when I open up a browser and enter "192.168.168.1:8080" in the url bar, it tells me after a while that the connection timed out.

我可以毫无问题地从我的 Windows 机器 ping linux 服务器.

I can ping the linux server from my windows machine with no problems.

是否需要针对 tomcat/linux 服务器进行配置,以便我能够从本地计算机调用 tomcat?

Is there something I need to configure with respect to tomcat/the linux server in order for me to be able to call tomcat from my local machine?

推荐答案

1) 服务器端的测试告诉您 localhost 正在解析为 ipv4 和 ipv6 环回地址,但可能不会解析为 192.168.168.1:
解析本地主机(localhost)... ::1, 127.0.0.1

1) the test at server side is telling you that localhost is resolving to ipv4 and ipv6 loopback addresses but probably not to 192.168.168.1:
Resolving localhost (localhost)... ::1, 127.0.0.1

2) 检查tomcat绑定的IP地址
netstat -nltss -nlt
如果您看到类似
的条目tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
这意味着 tomcat 绑定到所有可用的 IP,那么这是您的主机或服务器上的防火墙问题.

2) Check what IP addresses is tomcat bind to with
netstat -nlt or ss -nlt
If you see an entry like
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
meaning that tomcat is bind to all available IPs, then it's a firewall problem on your host or on server.

如何解决

  • 检查防火墙.
  • 检查 server.xml 中的 address 属性,如果显示 localhost,请将其更改为 0.0.0.0192.168.168.1

  • Check firewalls.
  • Check address attribute at server.xml, if it says localhost, change it to 0.0.0.0 or 192.168.168.1

<连接器端口=8080"协议=HTTP/1.1"地址="0.0.0.0"连接超时=20000"maxPostSize="2147483647"redirectPort="8443"/>

要进行测试,请在服务器端运行 wget http://192.168.168.1.1:8080,然后从浏览器进行测试.
连接器元素的Tomcat官方文档

To test, run wget http://192.168.168.1.1:8080 on server side, then test from your browser.
Tomcat official doc for Connector element

这篇关于无法访问远程linux服务器上的tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆