Project

General

Profile

Application in Apache using httpd

Added by Manuel Villalba about 2 months ago

I am trying to set up an httpd application that uses enableUpdates() with an Apache reverse proxy in between. When I connect directly without going through Apache, everything works perfectly.

When I connect through Apache, with one session, it works fine, but when there are multiple sessions, all the sessions that go through Apache are blocked for the duration of the ProxyPass timeout.

I have been testing, and I see the same behavior in the simplechat example , which also uses enableUpdates(). I'm using wt version 4.11.0

I noticed that if I disable enableUpdates, it doesn’t freeze, but my application stops receiving UI updates.

I don’t want to use fcgi because it has caused problems in the past, and I’ve seen that it is now deprecated.

I have also configured the wt_config.xml with:

                <trusted-proxy-config>
                        <original-ip-header>X-Forwarded-For</original-ip-header>
                        <trusted-proxies>
                                <proxy>126.0.0.1/8</proxy>
                                <proxy>::0/128</proxy>
                        </trusted-proxies>

My Apache configuration is as follows:

<Proxy *>
    Require all granted
</Proxy>

ProxyPreserveHost On
ProxyRequests On

ProxyPass / http://127.0.0.1:8080/ timeout=60 nocanon
ProxyPassReverse / http://127.0.0.1:8080/

KeepAlive Off
Timeout 60

Many thanks for your time and assistance


Replies (6)

RE: Application in Apache using httpd - Added by Matthias Van Ceulebroeck about 1 month ago

Hello Manuel,

I haven't used Apache for this myself, we always rely on HAProxy.

Now, what I think may be happening in case of enableUpdates is that a single connection remains open longer than Apache likes (and triggers the timeout). I think that by default long polling will wait for two minutes.
In case you are using WebSockets, as to not have connections open and close constantly, you'll need to ensure the singular connection can remain alive for the duration of the whole session.

I personally do NOT see the behavior of the blocked requests in case of multiple sessions. I tested by running the widget gallery locally, and the simplechat example. They both work fine for me.
The only thing I changes from your config is the proxy to run it all locally. Admittedly, since it is the same host, this will likely not cause proxy deviations.

I can only say that perhaps: <proxy>126.0.0.1/8</proxy> ought to be <proxy>127.0.0.1/8</proxy>?

Best,
Matthias

RE: Application in Apache using httpd - Added by Manuel Villalba about 1 month ago

Hello Matthias,

Thank you for you answer.

I haven't used Apache for this myself, we always rely on HAProxy.

I can't switch to HAProxy easily because I have other services running with Apache and both would listen on the same ports by default (80 and 443)

Now, what I think may be happening in case of enableUpdates is that a single connection remains open longer than Apache likes (and triggers the timeout). I think that by default long polling will wait for two minutes.

I will try to find an Apache configuration in order to mitigate that.

In case you are using WebSockets

I'm not using WebSockets, I don't know if Wt uses it behind the scenes .

I can only say that perhaps: 126.0.0.1/8 ought to be 127.0.0.1/8?

I will correct that!

If I make any new discoveries I will share them here.

Thank you again.

RE: Application in Apache using httpd - Added by Matthias Van Ceulebroeck about 1 month ago

Hello Manuel,

I can't switch to HAProxy easily
Of course, I wasn't implying you should, just saying I often use it. I always hate answers that say "just use this", even though you specifically said you wanted to use another tool.

I'm not using WebSockets, I don't know if Wt uses it behind the scenes .
It will only do so, if it is enabled. The wt_config.xml has a web-sockets configuration option to enable/disable this.

Hopefully you are able to make it work!

Best,
Matthias

RE: Application in Apache using httpd - Added by Manuel Villalba about 21 hours ago

Hello, we got it working!

The issue was caused by an active HTTP/2 module in Apache (which we weren’t even using). Once we disabled it, the website started working much more reliably.

We realized this because, on a clean Debian 12 installation, it worked perfectly from the start.

Thanks for the help! This thread can be closed as the issue is resolved.

RE: Application in Apache using httpd - Added by Matthias Van Ceulebroeck about 20 hours ago

Thanks for the update! Good to hear you got it working.

Could you share which module was "misbehaving"? This can be handy for posterity.

RE: Application in Apache using httpd - Added by Manuel Villalba about 20 hours ago

Apache http2 official module

https://httpd.apache.org/docs/2.4/mod/mod_http2.html

root@machine:~# a2dismod http2
Module http2 disabled.
To activate the new configuration, you need to run:
  systemctl restart apache2
root@machine:~# systemctl restart apache2
    (1-6/6)