Restrict Tomcat to respond to natively requests only (GO)

Source: Internet
Author: User

Http://blog.bbzhh.com/index.php/archives/135.html

In the VPS to build the Nginx and Tomcat application, want to through Nginx to reverse proxy 127.0.0.1:8080 Tomcat external service, but 8080 port always provide listening to all the external address, the modification method has the following three kinds:
Scenario One: Use a firewall to intercept port 8080
This is the first can think of the practice, directly in the iptables to do it, do not make too many statements;

Scenario Two: Modify the Tomcat global listener only 127.0.0.1
In $catalina_home/conf/server.xml, find a tab segment similar to the following description 8080 listener:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />

Add: address= "127.0.0.1" in this tab
When you are done:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" address="127.0.0.1" redirectPort="8443" />

All of the applications released under Tomcat can only be accessed by 127.0.0.1.

Scenario Three: Modify an app under Tomcat to listen only 127.0.0.1
Find the label for the application path configuration in $catalina_home/conf/server.xml, for example:

<context path="/blog" reloadable="true" docBase="/var/www/blog" />

After adding the listener bindings in the Context tab, modify to:

<context path="/blog" reloadable="true" docBase="/var/www/blog"> <value className="org.apache.catalina.values.RemoteAddrValue" allow="127.0.0.1" deny="" /></context>

It can also be set to be accessed by specific address segments, such as allowing access only to IP segments such as 192.168.1.0-192.168.5.255 and 192.168.10.0-192.168.15.255:

<context path="/blog" reloadable="true" docBase="/var/www/blog"> <value className="org.apache.catalina.values.RemoteAddrValue" allow="192.168.[1-5].*,192.168.[10-15].*" deny="" /></context>

The above scenarios for Tomcat configuration file modifications are in effect after you restart Tomcat

Restrict Tomcat to respond to natively requests only (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.