VAT
Status
Back to Community

How to Install WildFly Application Server with Nginx Reverse Proxy on Debian 13/Ubuntu 24.04

TutorialsCategory
HostFactor TeamAuthor

How to Install WildFly Application Server with Nginx Reverse Proxy on Debian 13/Ubuntu 24.04

WildFly (formerly JBoss AS) is a powerful, lightweight, and flexible application server for deploying Java-based enterprise applications. In this guide, we'll walk you through installing WildFly on Debian 13 or Ubuntu 24.04 and configuring Nginx as a reverse proxy to handle HTTP traffic.

🐝 What is WildFly?

WildFly is an open-source application server written in Java that provides a platform for deploying and running enterprise Java applications. Key features include:

  • Lightweight - Fast startup and low memory footprint
  • Jakarta EE Certified - Full support for enterprise Java standards
  • Modular Architecture - Load only what you need
  • Fast Provisioning - Quick deployment with WildFly Swarm
  • Cloud-Native - Ready for containerization and Kubernetes
  • Free and Open Source - No licensing costs

📋 Prerequisites

Before You Begin:

  • ☑️ Server - Debian 13 or Ubuntu 24.04
  • ☑️ Root Access - sudo or root privileges
  • ☑️ Java JDK - Java 11 or higher
  • ☑️ Domain Name - Pointing to your server (optional)
  • ☑️ Firewall - Ports 80, 443, and 8080 open

☕ Step 1: Install Java Development Kit

WildFly requires Java to run. Let's install OpenJDK 17 (LTS version):

1.1 Update System Packages

# Debian 13
sudo apt update && sudo apt upgrade -y

# Ubuntu 24.04
sudo apt update && sudo apt upgrade -y

1.2 Install OpenJDK 17

# Install OpenJDK 17 JDK
sudo apt install openjdk-17-jdk -y

# Verify installation
java -version

# Check JAVA_HOME
echo $JAVA_HOME

1.3 Set JAVA_HOME Environment Variable

# Find Java installation path
readlink -f $(which java)

# Usually it's /usr/lib/jvm/java-17-openjdk-amd64
# Add to ~/.bashrc or /etc/environment
echo "JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64" | sudo tee -a /etc/environment

# Apply immediately
source /etc/environment

# Verify
echo $JAVA_HOME

📥 Step 2: Download and Install WildFly

2.1 Create WildFly User

# Create dedicated user for WildFly
sudo useradd -r -s /bin/false wildfly

# Create installation directory
sudo mkdir -p /opt/wildfly
sudo chown wildfly:wildfly /opt/wildfly

2.2 Download WildFly

# Navigate to installation directory
cd /opt/wildfly

# Download latest WildFly (check for latest version at wildfly.org)
sudo wget https://github.com/wildfly/wildfly/releases/download/34.0.1.Final/wildfly-34.0.1.Final.tar.gz

# Extract the archive
sudo tar -xzf wildfly-34.0.1.Final.tar.gz

# Rename for easier access
sudo mv wildfly-34.0.1.Final wildfly-server

# Set ownership
sudo chown -R wildfly:wildfly /opt/wildfly

2.3 Configure WildFly Environment

# Create wildfly.conf in /etc/default/
sudo nano /etc/default/wildfly

# Add the following:
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
WILDFLY_HOME="/opt/wildfly/wildfly-server"
WILDFLY_USER="wildfly"
WILDFLY_BIND="0.0.0.0:8080"

2.4 Create Systemd Service

sudo nano /etc/systemd/system/wildfly.service

# Add the following:
[Unit]
Description=WildFly Application Server
After=network.target

[Service]
Type=simple
User=wildfly
Group=wildfly
ExecStart=/opt/wildfly/wildfly-server/bin/launch.sh -b 0.0.0.0 -c default
ExecStop=/opt/wildfly/wildfly-server/bin/jboss-cli.sh --connect command=:shutdown
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

2.5 Enable and Start WildFly

# Reload systemd
sudo systemctl daemon-reload

# Enable WildFly to start on boot
sudo systemctl enable wildfly

# Start WildFly
sudo systemctl start wildfly

# Check status
sudo systemctl status wildfly

🌐 Step 3: Configure Nginx as Reverse Proxy

3.1 Install Nginx

# Install Nginx
sudo apt install nginx -y

# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx

# Check status
sudo systemctl status nginx

3.2 Create Nginx Configuration

# Create configuration file
sudo nano /etc/nginx/sites-available/wildfly

# Add the following:
server {
    listen 80;
    server_name your-domain.com;

    location / {
        proxy_pass http://127.0.0.1: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;
        
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        
        # Timeouts
        proxy_connect_timeout 300s;
        proxy_send_timeout 300s;
        proxy_read_timeout 300s;
    }

    # Optional: Serve static files directly
    location /static {
        alias /opt/wildfly/wildfly-server/standalone/deployments/static;
        expires 30d;
        add_header Cache-Control "public, immutable";
    }
}

3.3 Enable the Configuration

# Create symbolic link
sudo ln -s /etc/nginx/sites-available/wildfly /etc/nginx/sites-enabled/

# Test Nginx configuration
sudo nginx -t

# Reload Nginx
sudo systemctl reload nginx

3.4 Configure WildFly for Reverse Proxy

# Edit WildFly configuration
sudo nano /opt/wildfly/wildfly-server/standalone/configuration/standalone.xml

# Find the <host> section and add proxy-address-forwarding:
<host name="default-host" alias="localhost" >
    <location name="/" handler="welcome-content" />
    <filter-ref name="server-header"/>
    <filter-ref name="x-powered-by-header"/>
</host>

# Add under <server> element:
<server name="default-server">
    <http-listener name="default" socket-binding="http" proxy-address-forwarding="true" />
</server>

🔒 Step 4: Secure with SSL Certificate

4.1 Install Certbot

# Install Certbot
sudo apt install certbot python3-certbot-nginx -y

4.2 Obtain SSL Certificate

# Get certificate (replace with your domain)
sudo certbot --nginx -d your-domain.com -d www.your-domain.com

# Follow the prompts
# Enter email for renewal notices
# Agree to terms of service
# Choose redirect HTTP to HTTPS (recommended)

4.3 Auto-Renewal

# Test automatic renewal
sudo certbot renew --dry-run

# Check renewal timer
systemctl list-timers | grep certbot

⚙️ Step 5: WildFly Administration Console

5.1 Enable Admin Console

# Create admin user
cd /opt/wildfly/wildfly-server/bin
sudo ./add-user.sh

# Select "Management User" (a)
# Enter username and password
# Answer "yes" to other prompts

5.2 Access Admin Console

# The admin console is available at:
# http://your-domain.com:9990/management

# Or configure Nginx to proxy port 9990:
# Add to Nginx config:
location /management {
    proxy_pass http://127.0.0.1:9990;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
}

📦 Step 6: Deploy Your First Application

6.1 Deploy via Admin Console

  1. Navigate to http://your-domain.com:9990/management
  2. Log in with your admin credentials
  3. Go to "Deployments" tab
  4. Click "Add" and upload your .war file
  5. Enable the deployment

6.2 Deploy via Command Line

# Copy WAR file to deployments folder
sudo cp your-app.war /opt/wildfly/wildfly-server/standalone/deployments/

# WildFly will auto-deploy
# Check logs
sudo tail -f /opt/wildfly/wildfly-server/standalone/log/server.log

6.3 Deploy via JBoss CLI

# Connect to WildFly
cd /opt/wildfly/wildfly-server/bin
./jboss-cli.sh

# Deploy application
connect
deploy /path/to/your-app.war --runtime-name=your-app.war

# Check deployment status
deployment-info

🔧 Step 7: Performance Tuning

7.1 JVM Memory Settings

# Edit startup script
sudo nano /opt/wildfly/wildfly-server/bin/standalone.conf

# Add/modify JVM settings:
JAVA_OPTS="-Xms512m -Xmx2048m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -Djava.net.preferIPv4Stack=true"

7.2 Connection Pool Configuration

# In standalone.xml, add datasource connection pool:
<subsystem xmlns="urn:jboss:domain:datasources:5.0">
    <datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS">
            <connection-pool min-size="5" max-size="20" prefill="true"/>
        </datasource>
    </datasources>
</subsystem>

7.3 Thread Pool Tuning

# In standalone.xml, configure IO subsystem:
<subsystem xmlns="urn:jboss:domain:io:3.0" worker="default">
    <worker name="default" task-max-threads="200" io-threads="16"/>
</subsystem>

🛠️ Step 8: Troubleshooting

Common Issues and Solutions:

WildFly Won't Start

  • Check Java is installed: java -version
  • Verify JAVA_HOME is set correctly
  • Check port 8080 is not in use: netstat -tlnp | grep 8080
  • Review logs: tail -f /opt/wildfly/wildfly-server/standalone/log/server.log

Nginx 502 Bad Gateway

  • Verify WildFly is running: systemctl status wildfly
  • Check WildFly is listening on port 8080: curl http://localhost:8080
  • Review Nginx error logs: sudo tail -f /var/log/nginx/error.log

Application Deployment Fails

  • Check WAR file is valid
  • Verify Java version compatibility
  • Check database connection settings
  • Review deployment logs for errors

✅ Conclusion

Congratulations! You now have a fully functional WildFly application server with Nginx reverse proxy running on Debian 13 or Ubuntu 24.04. Your Java applications are now accessible via HTTP/HTTPS with the performance benefits of Nginx.

Remember to:

  • Keep WildFly and Java updated
  • Monitor server resources and logs
  • Configure proper backup strategies
  • Secure your admin console access
  • Use SSL certificates for production sites

WildFly provides an excellent platform for deploying enterprise Java applications. With Nginx handling static content and load balancing, your applications will be fast, secure, and scalable.

🚀 Get Your Java Hosting at HostFactor

Looking for a reliable VPS to host your WildFly applications? HostFactor.eu offers:

  • High-Performance VPS - Optimized for Java applications
  • Pre-Installed Java - Ready to deploy out of the box
  • Expert Support - Our team can help install and configure WildFly
  • 99.9% Uptime - Reliable infrastructure for your applications
  • Competitive Pricing - Affordable hosting solutions
  • Daily Backups - Your data is safe with us

Visit hostfactor.eu today to get started with your Java hosting!

CHAT WITH SALES