Question

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>

He got error 403 denied access .


Then I tried

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

This restricted my own computer from accessing .

What is the issue with my context.xml

No correct solution

OTHER TIPS

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).

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.

You have to use the RemoteHostValve instead of RemoteAddrValve, and use the FQDN of the host. So, if your domain is mydomain.com, use:

<Context>
    <Valve className="org.apache.catalina.valves.RemoteHostValve"
        allow="myFriendsComputerName.mydomain.com"
    />
</Context>

You can use nslookup to discover how your host will resolve your friend IP address to a host name:

nslookup x.y.w.z
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top