In practice, I typically find myself running WildFly behind an Apache reverse proxy. While configuring Apache is easy, I found the corresponding setup for WildFly hard to find in the depths of its documentation. Simply putting your installation behind the proxy is not enough, you need to perform additional configuration steps to ensure things like UriInfo in JAX-RS work correctly. Here’s a simple 2-step guide:

Step 1

Let’s start by creating a new named configuration for a socket. We’ll name it proxy-https and configure it to use port 443 for TLS. This can be accomplished with the following JBoss CLI snippet:

/socket-binding-group=standard-sockets/socket-binding=proxy-https\
:add(port=443)

Alternatively, you can add a socket-binding element to the socket-binding-group element in your WildFly configuration (e.g. standalone.xml):

<socket-binding-group name="standard-sockets" default-interface="public"
  port-offset="${jboss.socket.binding.port-offset:0}">
    ...
    <socket-binding name="proxy-https" port="443"/>
    ...
</socket-binding-group>

Step 2

We enable proxy address forwarding on our HTTP listener in the configuration of the Undertow subsystem and make it use the socket binding we created in Step 1. The following CLI script gets the job done:

/subsystem=undertow/server=default-server/http-listener=default\
:write-attribute(name=proxy-address-forwarding,value=true)
/subsystem=undertow/server=default-server/http-listener=default\
:write-attribute(name=redirect-socket,value=proxy-https)

The corresponding XML configuration looks like this:

<subsystem xmlns="urn:jboss:domain:undertow:3.0">
    ...
    <server name="default-server">
        ...
        <http-listener name="default" socket-binding="http" 
          proxy-address-forwarding="true" redirect-socket="proxy-https"/>
        ...
    </server>
    ...
</subsystem>

The full CLI script is available as a gist on GitHub. This example has been tested with WildFly 10, but the setup should be basically the same for other versions. Note that you don’t need a reverse proxy to support TLS on WildFly. See Undertow documentation for more details.