Sunday, 19 January 2025

Enable Remote Access to Tomcat Manager

 

Step 1: Install Apache Tomcat

Before we start, make sure you have Apache Tomcat installed on your server or computer. If you haven’t installed it yet, you can download it from the official Tomcat website and follow the installation instructions.

Step 2: Locate the Tomcat Configuration File

  1. Open the folder where Tomcat is installed.
  2. Find the conf directory.
  3. In this directory, locate the tomcat-users.xml file. This file is used to manage users and roles.

Step 3: Edit the tomcat-users.xml File

  1. Open the tomcat-users.xml file with a text editor.
  2. Add the following lines inside the <tomcat-users> tags to create a user with the manager role:
    
    <role rolename="manager-gui"/>
    <user username="admin" password="admin_password" roles="manager-gui"/>
    
    
  3. Replace admin with your desired username and admin_password with a strong password.

    ADVERTISEMENT

  4. Save the changes and close the file.

Step 4: Allow Remote Access To Manager App

  1. Go to the webapps/manager/META-INF/ directory.
  2. Open the context.xml file located in that directory with a text editor.
  3. Find the section that looks like this:
    
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
    
    
  4. Change the allow attribute to include your IP address or a range of IP addresses from which you want to allow access. For example:
    
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192\.168\.1\.\d+" />
    
    

    This example allows access from any IP address in the 192.168.1.x range.

  5. Save the changes and close the file.

Step 5: Allow Remote Access To Host Manager

  1. Go to the webapps/host-manager/META-INF/ directory.
  2. Open the context.xml file located in webapps/host-manager/META-INF/ directory with a text editor.
  3. Find the section that looks like this:
    
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
    
    
  4. Change the allow attribute to include your IP address or a range of IP addresses from which you want to allow access. For example:
    
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
        allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|192\.168\.1\.\d+" />
    
    

    This example allows access from any IP address in the 192.168.1.x range.

    ADVERTISEMENT

  5. Save the changes and close the file.

Step 6: Restart Tomcat

For the changes to take effect, you need to restart Tomcat. You can do this by running the shutdown script followed by the startup script located in the bin directory of your Tomcat installation:

  • For Windows:
    
    shutdown.bat
    startup.bat
    
    
  • For Linux:
    Linux server distribution
    
    ./shutdown.sh
    ./startup.sh
    
    

Step 7: Access Tomcat Manager Remotely

Open a web browser and go to http://<your-server-ip>:8080/manager. You should see the Tomcat Manager login page. Enter the username and password you created in the tomcat-users.xml file.



======================

file edit

setenv.sh


export CATALINA_OPTS="$CATALINA_OPTS -Xms28672m"

export CATALINA_OPTS="$CATALINA_OPTS -Xmx28672m"

======================