如何允许/限制某些计算机名称访问 tomcat 服务器? [英] How to allow/restrict access to tomcat server for certain computer names?

查看:24
本文介绍了如何允许/限制某些计算机名称访问 tomcat 服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的电脑上打开了一个服务器.我所有在同一网络上的朋友都可以从他们的计算机访问它.但我只想让我的一个朋友访问.所以我尝试在我的 context.xml

I opened a server on my computer . All my friends who are on the same network are able to access it from their computers . But I want to let only one of my friends access . So i tried to write the following in my context.xml

<Context>
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="myFriendsComputerName"
    />
</Context>

他收到错误 403 denied access .

He got error 403 denied access .

然后我尝试了

<Context>
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="127\.0\.0\.1"
    />
</Context>

这限制了我自己的电脑访问.

This restricted my own computer from accessing .

我的 context.xml 有什么问题

推荐答案

RemoteAddrValve 始终使用 IP 地址.如果您想通过主机名进行限制,您需要使用 RemoteHostValve.请注意,您使用的是正则表达式,因此您可以根据需要匹配客户端主机名的一部分(但安全性稍差).

RemoteAddrValve always uses IP addresses. If you want to restrict by hostname, you want to use RemoteHostValve. Note that you are using regular expressions, so you can match part of a client's hostname if you want (but it will be somewhat less secure).

另请注意,如果您的服务器上已禁用 DNS 解析,您仍将与远程客户端的 IP 地址进行比较,因此您可能希望通过允许主机名或 IP 地址来进行 IP 回退.

Also note that if DNS resolution has been disabled on your server, you'll still be comparing against the remote client's IP address, so you probably want an IP-fallback by allowing either hostnames or IP addresses.

这篇关于如何允许/限制某些计算机名称访问 tomcat 服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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