Introduction
Apache Tomcat is an open-source implementation of the Java Servlet, JavaServer Pages, Java Expression Language, and Java WebSocket technologies. Nginx is a high-performance web server that can also be used as a reverse proxy. This tutorial will guide you through the process of installing Apache Tomcat 10 with Nginx acting as a reverse proxy on Debian 12.
Prerequisites
Before you begin, ensure you have:
- A Debian 12 server
- Root or sudo access to the server
- Basic knowledge of Linux command line
Step 1: Install Java Development Kit (JDK)
Apache Tomcat requires Java to be installed on your system. Install OpenJDK 11:
sudo apt update
sudo apt install default-jdk -y
Step 2: Install Apache Tomcat
Download and install Apache Tomcat 10:
cd /tmp
wget https://downloads.apache.org/tomcat/tomcat-10/v10.0.16/bin/apache-tomcat-10.0.16.tar.gz
sudo tar -xf apache-tomcat-10.0.16.tar.gz -C /opt
Step 3: Configure Apache Tomcat
Configure Apache Tomcat to run as a service:
sudo nano /etc/systemd/system/tomcat.service
Add the following content:
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/default-java
Environment=CATALINA_PID=/opt/apache-tomcat-10.0.16/temp/tomcat.pid
Environment=CATALINA_HOME=/opt/apache-tomcat-10.0.16
Environment=CATALINA_BASE=/opt/apache-tomcat-10.0.16
ExecStart=/opt/apache-tomcat-10.0.16/bin/startup.sh
ExecStop=/opt/apache-tomcat-10.0.16/bin/shutdown.sh
User=root
Group=root
Restart=always
[Install]
WantedBy=multi-user.target
Save and close the file, then reload systemd:
sudo systemctl daemon-reload
Start and enable Apache Tomcat:
sudo systemctl start tomcat
sudo systemctl enable tomcat
Step 4: Install and Configure Nginx
Install Nginx:
sudo apt install nginx -y
Create a new server block configuration file:
sudo nano /etc/nginx/sites-available/tomcat
Add the following content:
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;
}
}
Activate the server block by creating a symbolic link:
sudo ln -s /etc/nginx/sites-available/tomcat /etc/nginx/sites-enabled/
Test Nginx configuration for syntax errors:
sudo nginx -t
If the test is successful, reload Nginx to apply the changes:
sudo systemctl reload nginx
Step 5: Access Apache Tomcat via Nginx
Open your web browser and navigate to http://your_domain.com
. You should see the Apache Tomcat default landing page, indicating that Nginx is successfully acting as a reverse proxy for Apache Tomcat.
Conclusion
Congratulations! You have successfully installed Apache Tomcat 10 with Nginx acting as a reverse proxy on Debian 12. You can now deploy your Java web applications and access them via Nginx.
RDS CAL (Client Access License)
Keywords: windows vps uk, windows vps, uk windows vps, windows vps hosting uk, vps windows server, uk vps windows, vps windows, servidor vps windows, vps uk windows, vps with windows, virtual private server windows, windows virtual private server, windows vps server uk, vps for windows, servidores vps windows, vps windows uk, windows vps hosting, vps windows hosting, windows vps server, windows virtual private servers, vps on windows, vps windows servers, cheap windows vps uk, windowsvps, windows desktop vps, buy vps windows, windows server vps, windows 10 vps uk, rds services, rds cal, remote desktop services, remote desktop hosting
#windowsvps #vpshosting #ukvps #virtualserver #windowsvpsuk #vpsserver #hostingvps #cloudvps #windowsvpshosting #cheapvps #vpswithwindows #windowsserver #servervps #vpssolutions #vpswindows #rdscal #remotedesktop #remotedesktopvps #rds #windowsrds