The server running environment is Tomcat. The purpose is to allow only specific IP addresses to access a directory. One way is to configure the file server in tomcat. in conf, use RemoteAddrValve to control access to the virtual host. The server running environment is Tomcat. The purpose is to allow only specific IP addresses to access a directory,
One way is to use RemoteAddrValve to control access to the VM in the tomcat configuration file server. conf.
You can also use iptables rules. I personally prefer iptables.
For example, to prohibit access to the path http: // 192.168.137.254: 10000/managersns, only access from 192.168.137.101 is allowed.
- /Sbin/iptables-a input-I eth0-p tcp -- dport 10000-s 192.168.137.101-m string -- string "/managersns" -- algo bm-j ACCEPT/sbin/iptables- INPUT-I eth0-p tcp -- dport 10000-m string -- string "/managersns" -- algo bm-j DROP
- /Sbin/iptables-a input-I eth0-p tcp -- dport 10000-s 192.168.137.101-m string -- string "/managersns" -- algo bm-j ACCEPT
- /Sbin/iptables-a input-I eth0-p tcp -- dport 10000-m string -- string "/managersns" -- algo bm-j DROP
The preceding rule is for the eth0 NIC, which can be tracked and modified as needed.
Parameter description:
-M string
Use the string function. string is a module of iptables, that is, string matching.
-String "xxxx"
Define the string content, which can be any character in the URL. if you need to block some types of files or requests, this space is very large and can be imagined.
-Algo bm
Set the character matching query algorithm. Generally, you can use the bm algorithm by default. you can also set the kmp algorithm, which is a more complex algorithm, for more information, see Advanced Mathematics. (Bm = Boyer-Moore, kmp = Knuth-Pratt-Morris)
-J DROP
This is very effective when video websites are disabled on the company's network. set it on the gateway server:
- Iptables-a forward-m string -- string "ku6.com" -- algo bm-j DROP iptables-a forward-m string -- string "tudou.com" -- algo bm-j DROP iptables-A FORWARD -m string -- string "ououou.com" -- algo bm-j DROP
- Iptables-a forward-m string -- string "ku6.com" -- algo bm-j DROP
- Iptables-a forward-m string -- string "tudou.com" -- algo bm-j DROP
- Iptables-a forward-m string -- string "ouou.com" -- algo bm-j DROP
The meanings of parameters are as follows:
-A FORWARD
Add the FORWARD chain rule. the preceding rule is for enabling the routing function (that is, echo 1>/proc/sys/net/ipv4/ip_forward)
For direct access, you can use INPUT or OUTPUT.
Set the handling method of packets that meet this condition. DROP means discard, which is also the meaning of reject.
- Iptables-a input-m string -- string "stringname" -- algo bm-j DROP