Nicolas Forney Nicolas Forney - 4 months ago 32
Apache Configuration Question

Can we use Apache to deliver HTTP/2 connection for a java application server?

Here is the basic architecture I currently use to deliver access to web application (AngularJS on the front-end - JEE-JAX-RS for the back-end REST API):

Client -> Apache -> Application server (Java container - ex. tomcat)

The client browser connect to the application through HTTPS (handled by Apache) and Apache forwards the connection to the Java container (I'm using Oracle Weblogic).
Everything works fine. But now I'd like to use HTTP/2.

Apparently, HTTP/2 will be available only in JEE8 (Servlet v4) which means it will not be available in solution like Weblogic before a loooong time.

Actually I have two questions :


  1. Can I just activate Apache mod_http2 and configure my front-end
    (AngularJS) to communicate in HTTP/2 or is it also necessary for my
    application server to be able to handle HTTP/2 ?

  2. If Apache receive connection in HTTP/2 and forward it to the Java
    container through HTTP/1.1 or AJP will I still benefit from all the HTTP/2 advantages, even if part of the connection is not in HTTP/2 ?


Answer

Apache (and Nginx) do not currently have the capability to work in reserve-proxy mode and communicate to the backend using HTTP/2.

When you have such "mixed" communication (browser to Apache in HTTP/2 and Apache to backend in HTTP/1.1 or AJP) you are losing a number of optimizations that HTTP/2 brings, in particular multiplexing and HTTP/2 push, not to mention the overhead due to translating the request from HTTP/2 to HTTP/1.1 and viceversa.

HTTP/2 is already available in the Java world: Jetty (I am the Jetty HTTP/2 lead), Undertow and Netty already provide transparent HTTP/2 support so that you just deploy your JEE application, enable HTTP/2 and it's done.

Because of these limitations of Apache and Nginx, we currently recommend to use HAProxy in front of Jetty (as explained in details here). This configuration will give you the maximum benefit for HTTP/2: fast TLS offloading performed by HAProxy, powerful load balancing, very efficient communication with the backend (no translation to HTTP/1.1), with HTTP/2 everywhere and therefore all its benefits.

Jetty also offers an automatic HTTP/2 push mechanism, which is not available, to my knowledge, in Apache or Nginx.

Specifically for your questions:

  1. You can activate mod_http2 so that browser and Apache will communicate via HTTP/2, but you may lose HTTP/2 Push. Communication with the backend will use HTTP/1.1, however. This will work but it's not an optimal HTTP/2 deployment.
  2. You will not benefit of any HTTP/2 advantage in the communication between the client and the backend if part of the communication is not in HTTP/2.
Comments