How to install WildFly with Nginx as a reverse proxy on Ubuntu 16.04

wildfly ubuntuIn this tutorial we are going to provide you with step by step instructions on how to install WildFly with Nginx as a reverse proxy on an Ubuntu 16.04 VPS.
WildFly is a flexible and lightweight open source application server authored by JBoss, now developed by Red Hat.
At the moment of writing this article, WildFly 10 is the latest release in a series of JBoss open-source application server offerings.

Let’s start with the installation. Make sure your server OS packages are fully up-to-date:

apt-get update 
apt-get upgrade

Stop and remove Apache, then install nginx using the following commands:

service apache2 stop
apt-get remove apache2
apt-get autoremove
apt-get install nginx

Edit the default nginx configuration file:

vi /etc/nginx/sites-enabled/default

Delete the following line:

listen [::]:80 default_server;

Enable nginx service to start on boot and start it:

systemctl enable nginx
systemctl start nginx.service

In order to run WildFly, Java has to be installed on the server so run the following command to install the Java Development Kit package (JDK):

apt-get install default-jdk

To find out what version of Java has been installed, run:

java -version

The output should be something like this:

openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

Create a WildFly user:

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

Download the latest version of WildFly available at ‘’ to a directory on the server and extract it using the following commands:

cd /opt
tar -xvzf wildfly-10.0.0.Final.tar.gz
mv wildfly-10.0.0.Final wildfly

Create a wildfly configuration file:

vi /etc/default/wildfly

Add the following lines to it:


so it will start WildFly 10 using the default web profile configuration in ‘standalone’ mode.
Create a WildFly startup script, named ‘’:

vi /opt/wildfly/bin/

if [ "x$WILDFLY_HOME" = "x" ]; then

if [ "x$1" = "xdomain" ]; then
    echo 'Starting Wildfly in domain mode.'
    $WILDFLY_HOME/bin/ -c $2 -b $3
    echo 'Starting Wildfly in standalone mode.'
    $WILDFLY_HOME/bin/ -c $2 -b $3

Make the startup script executable:

chmod 755 /opt/wildfly/bin/

WildFly can be started using the script we created in the /opt/wildfly/bin directory or even better, we will create a systemd init file for that purpose:

vi /etc/systemd/system/wildfly.service
Description=The WildFly Application Server



Set the proper ownership of files and directories located to the /opt/wildfly directory:

chown wildfly:wildfly -R /opt/wildfly/

Start the WildFly service and enable WildFly to start on boot:

systemctl daemon-reload
systemctl start wildfly
systemctl enable wildfly

Create a new nginx block so you can access the WildFly management interface using nginx as a reverse proxy:

vi /etc/nginx/sites-available/wildfly

Add the following lines:

upstream wildfly {

server {
    listen      80;

    access_log  /var/log/nginx/wildfly.access.log;
    error_log   /var/log/nginx/wildfly.error.log;

    proxy_buffers 16 64k;
    proxy_buffer_size 128k;

location / {
        proxy_pass  http://wildfly;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_redirect off;

        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 https;


Do not forget to replace ‘’ with your actual domain name.

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

Restart nginx for the changes to take effect:

systemctl restart nginx.service

In order to access the WildFly management console, you need to add a new user. Execute the script within the bin directory of the WildFly installation and enter the requested information:


That is it. The WildFly installation is now complete.

To access the WildFly management console, open using the newly created user login credentials.
wildfly management console

Of course you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to install WildFly with Nginx as a reverse proxy for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

How to Install phpwcms on a CentOS 7 VPS
How to install Group-Office 6 on an Ubuntu 14.04 VPS
How to install Zend Framework on an Ubuntu VPS
There are currently no comments.