×

Install and Configure WildFly (JBoss) on Debian 11 - Step by step guide ?


Install and Configure WildFly (JBoss) on Debian 11 - Step by step guide ?

Wildfly is an open-source, cross-platform, and based on pluggable subsystems that can be added or removed as needed which provides all the necessary features to run a Java web application.

Basically, it is an application server written in Java and developed by RedHat and is a simple, lightweight, and powerful server with a CLI and an admin console. 

Here at Outsource Path, as part of our Server Management Services, we regularly help our Customers to perform related Open-source Software Installation queries.

In this context, we shall look into how to install Wildfly with Nginx as a reverse proxy on Debian 11.


Steps to install Wildfly with Nginx as a reverse proxy on Debian 11

1. Perform System Update

Before we install any software, it’s important to make sure your system is up to date by running these following apt commands in the terminal:

$ sudo apt update
$ sudo apt upgrade


2. Install Java JDK

Wildfly is a Java-based application so Java must be installed on your server. If not installed, you can install it by running the following command:

$ apt-get install default-jdk -y

Once Java is installed, you can verify it using the following command:

$ java --version

You should see the Java version in the output.


3. Install Wildfly

First, create a user and group to run the Wildfly application using the following command:

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

Next, download the latest version of Wildfly using the wget command:

$ wget https://github.com/wildfly/wildfly/releases/download/25.0.1.Final/wildfly-25.0.1.Final.zip

Once the download is completed, unzip the downloaded file with the following command:

$ unzip wildfly-25.0.1.Final.zip

Next, move the extracted directory to the /opt using the following command:

$ mv wildfly-25.0.1.Final /opt/wildfly

Next, change the ownership of /opt/wildfly directory:

$ chown -RH wildfly:wildfly /opt/wildfly

Next, create a Wildfly configuration directory inside /etc using the following command:

$ mkdir -p /etc/wildfly

Next, copy all necessary files from the Wildfly directory to the /etc/wildfly directory:

$ cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf /etc/wildfly/
$ cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/
$ cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/

Next, set execution permission to all shell script files:

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

Next, reload the systemd daemon with the following command:

$ systemctl daemon-reload

Next, start and enable the Wildfly service using the following command:

$ systemctl start wildfly
$ systemctl enable wildfly

To check the Wildfly service status, run the following command:

$ systemctl status wildfly


4. Enable Wildfly Admin Console

By default, the Wildfly admin console is disabled. It is recommended to enable it to manage the Wildfly application.

You can enable it by editing the Wildfly configuration file:

$ nano /etc/wildfly/wildfly.conf

Change the following lines:

WILDFLY_BIND=127.0.0.1
WILDFLY_CONSOLE_BIND=127.0.0.1

Save and close the file then edit the Wildfly launcher script and enable the admin console:

$ nano /opt/wildfly/bin/launch.sh

Change the file as shown 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 the file then edit the Wildfly systemd file:

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

Change the following line:

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

Save and close the file then reload the systemd daemon to apply the configuration changes:

$ systemctl daemon-reload

Next, restart the Wildfly service to apply the changes:

$ systemctl restart wildfly

You can also check the status of the Wildfly with the following command:

$ systemctl status wildfly

Now, Wildfly is started and listens on ports 8080 and 9990. You can check them with the following command:

ss -plnt


5. Create Wildfly Admin User

Next, you will also need to create an admin user to access the Wildfly admin console. You can create it by running the following command:

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

You will be asked to choose the types of user:

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): a
Type a and press the Enter key to add the management user. You will be asked to define your username and password as shown below:
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : hitesh
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 : 
Provide your username, password and press Enter. You will be asked to add users to the realm:
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: 
About to add user 'hitesh' for realm 'ManagementRealm'
Is this correct yes/no? yes

Type yes and press the Enter key to continue. Once the user is added, you will get the following output:

Added user 'hitesh' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'
Added user 'hitesh' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'
Added user 'hitesh' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'
Added user 'hitesh' with groups  to file '/opt/wildfly/domain/configuration/mgmt-groups.properties'
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 Jakarta Enterprise Beans calls.
yes/no? yes
To represent the user add the following to the server-identities definition 

Once you are finished, you can proceed to the next step.


6. Install and Configure Nginx as a Reverse Proxy

Next, you will need to configure the Nginx as a reverse proxy to access the Wildfly through port 80.

First, install the Nginx package using the command below:

$ apt-get install nginx -y

Once the Nginx is installed, create an Nginx proxy file with the following command:

$ nano /etc/nginx/conf.d/proxy_headers.conf

Add the following lines:

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 the file then create an Nginx virtual host configuration file for Wildfly:

$ nano /etc/nginx/conf.d/wildfly.conf

Add the following lines:

server {
  listen          80;
  server_name     wildfly.yourdomain.com;
  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 the file then verify the Nginx for any syntax error using the following command:

$ nginx -t

You should see the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finally, restart the Nginx service to apply the changes:

$ systemctl restart nginx

You can also check the Nginx status using the command below:

$ systemctl status nginx


How to access Wildfly Web UI ?

Now, open your web browser and access the Wildfly application page using the URL http://wildfly.yourdomain.com

You should see the Wildfly default page.

To access the Wildfly admin console type the URL http://wildfly.yourdomain.com/console/ in your web browser. You will be asked to provide an admin username and password.

Provide your admin username, password and click on the Sign in button. Once you are logged in, you should see the Wildfly admin dashboard.


[Need help in fixing Nginx configuration issues ? We can help you. ]

Who We Are ?

Most prominent, efficient, and well-performing IT companies and software solutions.

Related Posts