Slow response of WildFly behind a reverse proxy

reverse-proxywildfly8

we are running WildFly 8.1 on our Servers. To make our application accessible on port 80 we use apache with mod_proxy. We pass every request on port 80 to WildFly. The problem is that this is very slow. For example if we access the application directly without the proxy the loading time is about 2 seconds. Through the proxy it is about 20 seconds.

We used the same proxy configuration with an other application server without any problem. Furthermore we tried it with nginx as proxy too. Same problem. Moreover we can't find any information about this in the internet. The problem was posted in the WildFly-Forum too (see https://developer.jboss.org/thread/251358). But no response until now. If anyone would have an idea what could be wrong, please let us now.

thanks in advance

EDIT:
We found out that normal HTML-pages are loaded without any problems but for example java-scripts are loaded slowly. It seems that it has something todo with the file size. Small JavaScripts (for testing with 2 lines) are loaded without any problems. Others take almost a minute. We captured the network traffic. It seems that a lot of TCP-Connection-Alive packages are sent. When we open one javascript file in the browser it appears immediatly but the browser is still loading and showing "transfering data".

Best Answer

I had the same problem on Windows. I solved it by change url in proxy_pass.

Before change:

proxy_pass http://localhost;

After change:

proxy_pass http://127.0.0.1;

The problem is caused because localhost can be resolved as an ipv6 address (::1) and an ipv4 address (127.0.0.1) and the backend is not listening on both interfaces.

You can read more here: https://trac.nginx.org/nginx/ticket/496#ticket