Skip to content

Installing Apache Tomcat 11.0.7 alongside Nginx on Ubuntu 24.04

Guide on setting up Apache Tomcat 11.0.7 along with Nginx on Ubuntu 24.04 for optimal Java web application hosting. Adhere to this comprehensive walkthrough.

Instructions for Setting Up Apache Tomcat 11.0.7 Alongside Nginx on Ubuntu 24.04 Operating System
Instructions for Setting Up Apache Tomcat 11.0.7 Alongside Nginx on Ubuntu 24.04 Operating System

Installing Apache Tomcat 11.0.7 alongside Nginx on Ubuntu 24.04

In this article, we'll guide you through the best practices for deploying a Java web application using Apache Tomcat 11.0.7 and Nginx on Ubuntu 24.04 LTS. This combination offers an efficient, versatile, and secure solution for hosting Java web applications.

Preparing the Ubuntu 24.04 Environment

  1. Update the system packages to ensure you have the latest security patches.
  2. Install Java (preferably Java 17 or newer, such as Temurin 21 JDK) because Tomcat 11 requires Java 11 or above.
  3. Install Apache Tomcat 11.0.7 either by downloading from the official Apache Tomcat website or using a package manager if available.
  4. Create a system user for Tomcat (Step 5).

Configuring Apache Tomcat

  • Deploy your Java web application as a WAR file inside Tomcat’s directory.
  • For better control, rename your WAR file to to make the application the default web app.
  • Ensure proper Tomcat user permissions and configure Tomcat server settings as needed for your production environment.

Installing and Configuring Nginx as a Reverse Proxy

  1. Install Nginx on Ubuntu via .
  2. Configure Nginx to act as a reverse proxy forwarding HTTP/HTTPS requests to Tomcat (usually listening on port 8080).
  3. Example minimal Nginx config for this:``` server { listen 80; server_name your.domain.com;location / { proxy_pass http://localhost:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } ``` 4. This improves security, enables SSL termination at Nginx, and allows load balancing or caching if needed.

Optional: Use Containerization

  • Build Docker images for both Tomcat (with your Java WAR deployed) and Nginx.
  • Use Docker Compose to define a multi-container setup with Tomcat and Nginx communicating internally.

Security and Performance Best Practices

  • Run Tomcat and Nginx under dedicated users with minimal privileges.
  • Secure Tomcat Manager and Host Manager applications by disabling or restricting access.
  • Use HTTPS with Nginx — obtain certificates via Let’s Encrypt or other CAs.
  • Tune Tomcat and Nginx for your application load, e.g., adjusting thread pools, connection timeouts, caching headers.
  • Enable logging and monitoring for both Tomcat and Nginx.

Automation and Deployment Pipelines

  • Automate builds of your Java WAR using Maven or Gradle.
  • Integrate Docker build and deployment in CI/CD pipelines.
  • Use service managers (systemd) to run Tomcat as a background service.
  • Regularly update Tomcat, Java, Ubuntu, and Nginx to patch vulnerabilities.

In summary, the best practice is to have Nginx as a reverse proxy in front of Tomcat, running a properly packaged Java WAR on Tomcat 11 with Java 17+, all on a secured, updated Ubuntu 24.04 system. Containerization with Docker can further improve deployment consistency and scalability if appropriate.

For example configuration files or a sample Docker Compose stack for this setup, feel free to reach out! Using Apache Tomcat 11.0.7 with Nginx on Ubuntu 24.04 provides a reliable and performant stack for deploying Java web applications.

Here are the sentences containing ['lifestyle', 'home-and-garden', 'data-and-cloud-computing', 'technology'] and following from the given text:

  1. For a modern home-and-garden enthusiast, having a smart home technology system could be an attractive lifestyle addition, integrating control of numerous household appliances into a single platform.
  2. On the other hand, data-and-cloud computing professionals might prioritize working on cutting-edge projects related to artificial intelligence, SaaS platforms, or blockchain technology as a reflection of their passionate and innovative lifestyle.

Read also:

    Latest