Jetty Logo
Version: 9.3.7.v20160115
Contact the core Jetty developers at

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Configuring Jetty for FastCGI

Configuring Jetty to Proxy HTTP/2 to FastCGI

In this section you will see how to configure Jetty to serve WordPress via FastCGI.

The first step is to have WordPress installed in your server machine, for example under /var/www/wordpress. For more information about how to install WordPress, please refer to the WordPress Installation Guide.

The second step is to install php-fpm and make sure it is configured to listen on a TCP socket; typically it is configured to listen to localhost:9000.

The third step is to install Jetty, for example under /opt/jetty, called in the following $JETTY_HOME. Refer to Downloading Jetty for more information about how to install Jetty.

The fourth step is to create a Jetty base directory (see Managing Jetty Base and Jetty Home), called in the following $JETTY_BASE, where you setup the configuration needed to support FastCGI in Jetty, and configure the fcgi, http and deploy modules, so that Jetty will be able to accept HTTP requests from browsers, convert them in FastCGI, and proxy them to php-fpm:

$ mkdir -p /usr/jetty/wordpress
$ cd /usr/jetty/wordpress
$ java -jar $JETTY_HOME/start.jar --add-to-module=fcgi,http,deploy

Therefore $JETTY_BASE=/usr/jetty/wordpress.

The fifth step is to deploy the web application that provides the proxying of client requests to the FastCGI server, php-fpm. Typically this is done by deploying a *.war file in the $JETTY_BASE/webapps directory, but in case of FastCGI there is really nothing of this web application that you have to write: all the work is already done for you by the Jetty developers. Therefore you just need to deploy a Jetty XML file that configures the web application directly. Copy and paste the following content as $JETTY_BASE/webapps/jetty-wordpress.xml

Explanation of this file content:

The last step is to start Jetty (see Chapter 9, Starting Jetty) and hit http://localhost:8080 with your browser and enjoy WordPress:

$ java -jar /opt/jetty/start.jar

Configuring Jetty to Proxy HTTP/2 to FastCGI

In order to configure Jetty to listen for HTTP/2 requests from clients that are HTTP/2 enabled and forward them to the FastCGI server as FastCGI requests, you need to enable the http2 module, which in turn will require a TLS connector and consequently a keystore to read the key material required by TLS.

Enabling the http2 is really simple; in additions to the modules you have enabled above, add the http2 module:

$ java -jar $JETTY_HOME/start.jar --add-to-start=http2

The command above adds the http2 module (and its dependencies) to the existing modules and uses the default Jetty keystore to provide the key material required by TLS. You will want to use your own keystore with your own private key and certificate for your own domain.

Remember that by adding the http2 module, you will start two JVMs: one that reads the configuration, and one that has the ALPN boot boot jar in the boot classpath, as explained in Configuring HTTP/2.

Since now your site will run over TLS, you need to make sure that the WordPress URL is also configured so. If you have followed the steps of the previous section, your WordPress site is served at http://localhost:8080. You will need to change that to be https://localhost:8443 from the WordPress administration web interface, or follow the WordPress instructions to do so without using the administration web interface.

The minimal modules required to run WordPress with Jetty on HTTP/2 are therefore: http2, http, fcgi and deploy. These will setup a clear text connector on port 8080 for HTTP/1.1 and a TLS connector on port 8443 for HTTP/2 and HTTP/1.1.

At this point, you can start Jetty (see Chapter 9, Starting Jetty), hit http://localhost:8080 with your browser and enjoy WordPress via HTTP/2 using a HTTP/2 enabled browser:

$ java -jar $JETTY_HOME/start.jar

If you don't have a HTTP/2 enabled browser, WordPress will still be available over plain HTTP/1.1.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2016-02-12)