WildFly or previously known as JBoss AS is a lightweight implementation of the JEE (Java Enterprise Edition) container. Its flexible application runtime is written in Java that helps you build fantastic applications.

WildFly is a multi-platform application runtime running on Linux, macOS, and Windows operating systems. Created by JBoss Inc, and in 2006 was acquired by RedHat and become the WildFly.

In this tutorial, we will show you how to install WildFly on the latest Ubuntu 20.04. We will install the latest version of WildFly 20, enable admin console for WildFly, create the WildFly admin user, and setup Nginx as a reverse proxy for WildFly.

Prerequisites

For this guide, we will install WildFly on the latest Ubuntu Server 20.04 FocalFossa with 2 GB of RAM, 50 GB free disk space, and 2 CPUs.

What will we do?

  • Install Java OpenJDK 11
  • Add New User and Download WildFly
  • WildFly Basic Configuration
  • Enable WildFly Admin Console
  • Setup Admin User for WildFly
  • Setup Nginx as a Reverse Proxy for WildFly
  • Testing

Step 1 – Install Java OpenJDK

First, we will install the Java OpenJDK on the Ubuntu server 20.04. And we will be using the Java OpenJDK 11 for our WildFly installation, which is the default version of Java packages on the Ubuntu 20.04 repository.

Update all packages repository and install Java OpenJDK using the apt command below.

sudo apt update

sudo apt install default-jdk

Once all installation is completed, check the Java version using the following command.

java -version

Below is the result you will get.

openjdk version "11.0.7" 2020-04-14

OpenJDK Runtime Environment (build 11.0.7 10-post-Ubuntu-3ubuntu1)

OpenJDK 64-Bit Server VM (build 11.0.7 10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

As a result, the installation of Java OpenJDK on Ubuntu 20.04 has been completed.

Step 2 – Add New User and Download WildFly

In this step, we will create a new system user and group ‘wildfly’ and download the source code of wildfly to the ‘/opt/wildfly’ directory.

Now create a new user and group named ‘wildfly’ using the commands below.

groupadd -r wildfly

useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly

Next, go to the ‘/opt’ directory and download the wildfly source code using the wget command as below.

cd /opt/

wget -q wget https://download.jboss.org/wildfly/20.0.1.Final/wildfly-20.0.1.Final.tar.gz

The wildfly source code has been downloaded.

Now extract the wildfly source code and rename the extracted directory to ‘wildfly’.

tar -xf wildfly-20.0.1.Final.tar.gz

mv wildfly-20.0.1.Final wildfly

After that, change the ownership of the ‘wildfly’ directory to the ‘wildfly’ user and group.

chown -RH wildfly:wildfly /opt/wildfly

As a result, the wildfly installation directory is located at the ‘/opt/wildfly’ directory. The wildfly service will be running under the new user named ‘wildfly’ that we just created on top.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

Step 3 – WildFly Basic Configuration

After downloading the wildfly source code, we will set up the wildfly on the Ubuntu system.

Create new configuration directory ‘/etc/wildfly’ and copy the sample configuration ‘wildfly.conf’ into it.

mkdir -p /etc/wildfly

cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/

Next, copy the service file ‘wildfly.service’ to the ‘/etc/systemd/system’ directory.

cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

After that, copy the sample of wildfly launch script to the ‘/opt/wildfly/bin’ directory and make it executable.

cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/

chmod x /opt/wildfly/bin/*.sh

Now reload the systemd manager to apply the new ‘wildfly.service’ file.

systemctl daemon-reload

Start the wildfly service and add it to the system boot.Advertisement

systemctl start wildfly

systemctl enable wildfly

The wildfly service is up and running on the Ubuntu system with the default configuration.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

Check wildfly service using the following command.

ss -plnt

systemctl status wildfly

And you will get the result as below.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

As can be seen, the wildfly runs as a systemd service on the default TCP port ‘8080’ on the Ubuntu system.

Step 4 – Enable WildFly Admin Console

In this step, we will set up a wildfly to run on the local IP address ‘127.0.0.1’ and enable its admin console. We will edit the wildfly configuration ‘wildfly.conf’, wildfly start script ‘launch.sh’, and the wildfly service file ‘wildfly.service’.

Edit the wildfly configuration ‘/etc/wildfly/wildfly.conf’ using vim editor.

vim /etc/wildfly/wildfly.conf

Now change the value of ‘WILDFLY_BIND’ with the local IP address ‘127.0.0.1’.

WILDFLY_BIND=127.0.0.1

To enable the wildfly admin console, add the ‘WILDFLY_CONSOLE_BIND’ configuration below.

WILDFLY_CONSOLE_BIND=127.0.0.1

Save and close.

Next, edit the launch start script for wildfly ‘/opt/wildfly/bin/launch.sh’ using vim editor.

vim /opt/wildfly/bin/launch.sh

On the ‘domain.sh‘ and ‘standalone.sh‘ lines, add additional option to enable the wildfly admin console as below.

if [[ "$1" == "domain" ]]; then

    $WILDFLY_HOME/bin/domain.sh -c $2 -b $3 -bmanagement $4

else

    $WILDFLY_HOME/bin/standalone.sh -c $2 -b $3 -bmanagement $4

fi

Save and close.

Next, edit the default service file for wildfly ‘/etc/systemd/system/wildfly.service’ using vim editor.

vim /etc/systemd/system/wildfly.service

On the ‘ExecStart=/opt/wildfly/bin/launch.sh….‘ line, add the option ‘$WILDFLY_CONSOLE_BIND‘ as below.

ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND

Save and close.

Now reload the systemd manager and restart the wildfly service.

systemctl daemon-reload

systemctl restart wildfly

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

The wildfly service is running with the admin console enabled, check using the command below.

ss -plnt

systemctl status wildfly

Below is the result you will get.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

As a result, the wildfly runs on the local IP address ‘127.0.0.1‘ with the default TCP port ‘8080‘, and the wildfly admin console enabled on TCP port ‘9990‘.

Step 5 – Setup Admin user WildFly

In this step, we will create a new user for managing wildfly using the script ‘add-user.sh’ provided by wildfly.

Run the wildfly ‘add-user.sh’ script as below.

sh /opt/wildfly/bin/add-user.sh

For the type of user, type ‘a‘ to create the Management user (admin for managing wildfly).

What type of user do you wish to add? 

 a) Management User (mgmt-users.properties)

 b) Application User (application-users.properties)

(a): a

Now type your username and password, and make sure to use the secure password.

Enter the details of the new user to add.

Using the realm 'ManagementRealm' as discovered from the existing property files.

Username : hakase

Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.

 - The password should be different from the username

 - The password should not be one of the following restricted values {root, admin, administrator}

 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)

Password :

Re-enter Password :

For the group of the new user, just press ‘Enter‘ to continue.

What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:

Next, type ‘yes‘ to add your user to the ‘ManagementRealm‘ on wildfly.

About to add user 'hakase' for realm 'ManagementRealm'

Is this correct yes/no? yes

Added user 'hakase' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'

Added user 'hakase' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'

Added user 'hakase' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'

Added user 'hakase' with groups  to file '/opt/wildfly/domain/configuration/mgmt-groups.properties'

Type ‘yes‘ to enable your user as a process for managing the master-slave host controller of wildfly.

Is this new user going to be used for one AS process to connect to another AS process? 

e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.

yes/no? yes

To represent the user add the following to the server-identities definition

As a result, the admin and management user for wildfly has been created.

Step 6 – Setup Nginx as a Reverse proxy for WildFly

In this step, we will install and configure Nginx as a reverse proxy for the wildfly on the Ubuntu system.

Install Nginx packages using the apt command below.

sudo apt install nginx -y

Once all installation is finished, go to the ‘/etc/nginx/’ configuration directory.

cd /etc/nginx/

Create a new file ‘proxy_headers.conf’ under the ‘/etc/nginx/conf.d’ directory using vim editor.

vim conf.d/proxy_headers.conf

Paste the following configuration.

proxy_set_header Host $host;

proxy_set_header X-Forwarded-Proto $scheme;

add_header Front-End-Https on;

add_header Cache-Control no-cache;

Save and close.

Next, create a new virtual host configuration for wildfly under the ‘/etc/nginx/sites-available’ directory.

vim sites-available/wildfly

Change the IP address with your own and paste the configuration into it.

server {

  listen          80;

  server_name     SERVER-IP;

  location / {

    include conf.d/proxy_headers.conf;

    proxy_pass http://127.0.0.1:8080;

  }

  location /management {

    include conf.d/proxy_headers.conf;

    proxy_pass http://127.0.0.1:9990/management;

  }

  location /console {

    include conf.d/proxy_headers.conf;

    proxy_pass http://127.0.0.1:9990/console;

  }

  location /logout {

    include conf.d/proxy_headers.conf;

    proxy_pass http://127.0.0.1:9990/logout;

  }

  location /error {

    include conf.d/proxy_headers.conf;

    proxy_pass http://127.0.0.1:9990;

  }

}

Save and close.

Next, activate the wildfly virtual host and check the Nginx configuration.

ln -s /etc/nginx/sites-available/wildfly /etc/nginx/sites-enabled/

nginx -t

Now make sure there is no error, then restart the Nginx service.

systemctl restart nginx

As a result, the Nginx installation and configuration s a reverse proxy for wildfly has been completed.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

Step 7 – Testing

Open your web browser and type your server IP address on the address bar.

http://192.168.1.50/

Now you will get the wildfly default index page as below.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

Next, access the wildfly admin console on the URL path ‘/console’ as below.

http://192.168.1.50/console/

Log in using your wildfly admin user and password.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

Now you will get the wildfly admin dashboard as below.

How to Install WildFly Java Application Server with Nginx Reverse Proxy on Ubuntu 20.04 ubuntu

As a result, the installation of wildfly with Nginx reverse proxy on Ubuntu 20.04 Server has been completed successfully.