Tomcat 接受 IP 吗?

发布于 2024-08-04 22:00:09 字数 302 浏览 5 评论 0原文

我有一个 Tomcat 应用程序,它充当 Sun Systems Connect 的 Web 服务器/网关(它本身就是通往 Systems Union Accounts 的网关,我怀疑它是通向幸福的大门)。

只要使用计算机名称(或本地本地主机),我就可以通过浏览器访问应用程序的登录页面。 但机器 IP 和本地主机都不允许我看到登录页面。

Sun告诉我这是Tomcat的一个“功能”。不幸的是,开发和生产中的帐户机器具有相同的名称(不同的域),因此我无法判断我是否在开发盒或实时盒上运行测试。 如果不更改盒子名称,我可以强制 Tomcat 接受 IP 吗?

I have a Tomcat app that is acting as a web server/gateway to Sun Systems Connect (which is itself the gateway to Systems Union Accounts that I suspect is the gateway to happiness).

I can access the app's login page via a browser as long as I use the machine name (or localhost when local).
But neither the machines IP nor Localhost allows me to see the login page.

Sun tell me this is a 'feature' of Tomcat. Unfortunatly the accounts machines in development and in production have the same name (different domains) so I can't tell if I am running tests on the dev or live box.
Short of changing the box names can I force Tomcat to accept IPs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼趣 2024-08-11 22:00:10

http://tomcat.apache.org/tomcat-4.1-doc/ config/valve.html 讨论了强制进行 DNS 查找的resolveHosts 标志,也可能通过调整显示为 %A 参数之一的模式,您可以在日志中列出 IP 地址。

http://tomcat.apache.org/tomcat-4.1-doc/config/valve.html talks about a resolveHosts flag that forces a DNS lookup, also maybe with adjusting the pattern shown to one of the %A parameters you could list the IP address in the log.

擦肩而过的背影 2024-08-11 22:00:09

Tomcat 不知道任何有关 IP 的信息。 IP 仅被视为主机名。您需要确保配置允许该 IP。您有几种选择可以实现这一目标。

如果为引擎添加defaultHost,任何不匹配的主机名或IP都将使用该虚拟主机。例如,

<Engine name="Standalone" defaultHost="example.com">

如果您想要更多控制,您还可以将 IP 添加为别名,例如

<Host appBase="webapps" name="example.com">
   <Alias>192.168.1.2</Alias>
</Host>

IP 可能被拒绝的原因有很多,

  1. SSL 不允许 IP 因为证书不知道有关 IP 地址的任何信息。
  2. 如果您在 Apache 或前端交换机上使用虚拟主机,它通常根据您使用的主机名决定,并且不知道如何路由 IP。
  3. 您可能有一些安全过滤器或规则来检查 HTTP 中的主机标头,并专门删除来自未知主机的请求。

查看日志可能会告诉您确切的原因。

Tomcat doesn't know anything about IPs. IP is just treated as hostname. You need to make sure the configuration allows the IP. You have a few options to achieve this.

If you add a defaultHost for the engine, any non-matching hostname or IP will use this virtual host. For example,

<Engine name="Standalone" defaultHost="example.com">

If you want more control, you can also add the IP as an alias, like

<Host appBase="webapps" name="example.com">
   <Alias>192.168.1.2</Alias>
</Host>

There are many other reasons that an IP may be rejected,

  1. SSL doesn't allow IP because certificate doesn't know anything about IP address.
  2. If you use virtual host on Apache or a front-end switch, it normally based on the decision on the hostname you use and it doesn't know how to route IP.
  3. You may have some security filter or rule to check Host headers in HTTP and specifically drops requests from unknown hosts.

Looking at logs may show you the exact cause.

无可置疑 2024-08-11 22:00:09

我已经有一段时间没有使用 Tomcat 了,但我认为默认情况下您可以通过名称或 IP 地址调用 Web 服务。我不知道这是否有帮助,但您可以尝试设置 虚拟主机用于server.xml中的IP地址,例如添加类似的节

<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">

,但将“localhost”替换为您计算机的IP地址。

It's been a while since I used Tomcat, but I thought by default you could call the web service via either name or IP address. I don't know if this will help, but you could try setting a virtual host for the IP address in server.xml, e.g. add a stanza something like

<Host name="localhost" debug="0" appBase="webapps" unpackWARs="true">

but replacing "localhost" with your machine's IP address.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文