Tomcat8 restricts specified domain name or IP access

Keywords: Operation & Maintenance Apache xml Tomcat Attribute

Environmental Science:
  Tomcat8.0.53
Objectives:
Set to use the specified domain name or IP access

1. SET domain name access

1.1 open the server.xml file of the conf directory under Tomcat and find the following information

Modify Engine
engine specifies the default host name to process the request, which is at least the same as the name attribute value of one of the host elements

<Engine name="Catalina" defaultHost="www.678910.top">

1.2 find the following information again

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">

1.2.1 modify "localhost" in name="localhost" to the specified IP

<Host name="63.99.68.186"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->
    <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                 prefix="localhost_access_log" suffix=".txt"
                 pattern="%h %l %u %t "%r" %s %b" />
</Host>

1.2.2 modify "localhost" in name="localhost" to the specified domain name. Here, you need to specify an alias to ensure normal access with and without www

<Host name="www.678910.top"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    <Alias>678910.top</Alias>
    <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->
    <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                 prefix="localhost_access_log" suffix=".txt"
                 pattern="%h %l %u %t "%r" %s %b" />

</Host>

Reference from Tomcat8 configure domain name access Thank the original author for his selfless dedication

Posted by weemee500 on Fri, 06 Dec 2019 20:26:20 -0800