WildFly, developed by RedHat, is a lightweight and powerful application server written in Java. It offers a range of features to run Java web applications and is highly customizable with its pluggable subsystems. In this step-by-step guide, we will walk you through the process of installing and configuring WildFly on Debian 11, along with setting up Nginx as a reverse proxy.
Prerequisites
Before we proceed with the installation, make sure you have the following prerequisites in place:
- A server running Debian 11.
- A valid domain name pointed to your server’s IP address.
- A root password configured on your server.
Installing Java JDK
Since WildFly is a Java-based application, you need to have Java installed on your server. If you haven’t installed Java yet, follow these steps:
- Open the terminal on your Debian 11 server.
- Run the following command to install the default Java Development Kit (JDK):
apt-get installdefault-jdk -y
- Once the installation is complete, verify the Java version by running:
java --version
You should see the Java version displayed in the output, confirming a successful installation.
Installing WildFly
Now that Java is installed, let’s proceed with installing WildFly on your Debian 11 server:
- Create a user and group to run the WildFly application. Run the following commands:
groupadd -r wildfly useradd -r -g wildfly -d /opt/wildfly -s /sbin/nologin wildfly
- Download the latest version of WildFly using the
wget
command. Execute the following command:
wget https://github.com/wildfly/wildfly/releases/download/25.0.1.Final/wildfly-25.0.1.Final.zip
- Once the download is complete, unzip the downloaded file using the
unzip
command:
unzip wildfly-25.0.1.Final.zip
- Move the extracted directory to the
/opt
directory:
mv wildfly-25.0.1.Final /opt/wildfly
- Set the ownership of the
/opt/wildfly
directory to thewildfly
user and group:
chown -RH wildfly:wildfly /opt/wildfly
- Create a WildFly configuration directory inside
/etc
:
mkdir -p /etc/wildfly
- Copy the 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/
- Set the execution permission for all shell script files:
chmod +x /opt/wildfly/bin/*.sh
- Reload the systemd daemon to apply the changes:
systemctl daemon-reload
- Start and enable the WildFly service:
systemctl start wildfly systemctl enable wildfly
- Verify the status of the WildFly service to ensure it is running:
systemctl status wildfly
You should see the service status as “active (running)”, indicating a successful installation and startup of WildFly.
Enabling WildFly Admin Console
By default, the WildFly admin console is disabled, but it’s recommended to enable it for easier management of the WildFly application. Let’s enable the admin console:
- Open the WildFly configuration file using a text editor:
nano /etc/wildfly/wildfly.conf
- Locate the following lines in the file:
WILDFLY_BIND=127.0.0.1 WILDFLY_CONSOLE_BIND=127.0.0.1
- Change the IP addresses to
0.0.0.0
to allow access from any IP. Save and close the file. - Edit the WildFly launcher script:
nano /opt/wildfly/bin/launch.sh
- Find the following lines in the script:
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
- Replace these lines with the following code:
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 -Djboss.bind.address.management=0.0.0.0
fi
- Save and close the file.
- Edit the WildFly systemd file:
nano /etc/systemd/system/wildfly.service
- Find the following line in the file:
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND
- Replace this line with the following code:
ExecStart=/opt/wildfly/bin/launch.sh $WILDFLY_MODE $WILDFLY_CONFIG $WILDFLY_BIND $WILDFLY_CONSOLE_BIND-Djboss.bind.address.management=0.0.0.0
- Save and close the file.
- Reload the systemd daemon to apply the configuration changes:
systemctl daemon-reload
- Restart the WildFly service:
systemctl restart wildfly
- Verify the status of the WildFly service again:
systemctl status wildfly
The service status should show as “active (running)”, indicating that the admin console has been successfully enabled.
Installing and Configuring Nginx as a Reverse Proxy
To access WildFly through a standard HTTP port (port 80), we can set up Nginx as a reverse proxy. Follow the steps below to install and configure Nginx:
- Install the Nginx package:
apt-get install nginx -y
- Create an Nginx proxy file:
nano /etc/nginx/conf.d/proxy_headers.conf
- Add the following lines to the file:
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.
- Create an Nginx virtual host configuration file for WildFly:
nano /etc/nginx/conf.d/wildfly.conf
- Add the following lines to the file:
server { listen 80; server_name wildfly.example.io; 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; } }
Make sure to replace wildfly.example.io
with your actual domain name.
- Save and close the file.
- Verify the Nginx configuration for any syntax errors:
nginx -t
If there are no errors, the output should indicate a successful configuration.
- Restart the Nginx service to apply the changes:
systemctl restart nginx
- Verify the status of the Nginx service:
systemctl status nginx
The service status should show as “active (running)”, indicating that Nginx is successfully installed and configured as a reverse proxy for WildFly.
Accessing WildFly Web UI
Now that WildFly and Nginx are up and running, you can access the WildFly application page and the admin console through your web browser.
To access the WildFly application page, enter the URL http://wildfly.example.io
in your browser. You should see the default WildFly page, confirming a successful installation.
To access the WildFly admin console, use the URL http://wildfly.example.io/console/
. You will be prompted to enter the admin username and password. Provide the credentials you created earlier, and click on the “Sign in” button. Once logged in, you will have access to the WildFly admin dashboard, allowing you to manage and configure your Java applications.
Conclusion
Congratulations! You have successfully installed and configured WildFly (JBoss) on Debian 11, along with Nginx as a reverse proxy. With this setup, you can host and manage your Java applications with ease. WildFly’s lightweight nature, combined with Nginx’s reverse proxy capabilities, provides a powerful and scalable solution for your web application deployment needs.
Shape.host offers reliable and efficient cloud hosting solutions, including Linux SSD VPS, to further enhance your WildFly deployment. With Shape.host, you can enjoy high-performance hosting, exceptional support, and robust security features. Visit Shape.host today to empower your business with cutting-edge cloud hosting solutions.