Drupal Nginx
This post is adapted from a webinar hosted on January 20, 2016 by Floyd Smith and Faisal Memon of NGINX, Inc. It is the first of two parts, and is focused on site architecture and configuring NGINX for Drupal. The second part focuses on NGINX as a reverse proxy, load balancer, and content cache. You can also view the complete webinar on demand. Drupal with NGINX Container Image. Drupal is a PHP-based open-source content management platform. NGINX as the first choice for the webserver of your Drupal Site improves performance & sharply reduces memory utilization. NGINX is one of the most popular reverse proxy servers for a number of Drupal sites as it can handle the internet traffic and reduce the burden on your application server. Bitnami Drupal with NGINX Stack Containers Deploying Bitnami applications as containers is the best way to get the most from your infrastructure. Our application containers are designed to work well together, are extensively documented, and like our other application formats, our containers are continuously updated when new versions are made.
The Lagoon nginx-drupal
Docker image. Optimized to work with Drupal. Based on Lagoon nginx
image.
Lagoon & OpenShift adaptions¶

This image is prepared to be used on Lagoon, which leverages OpenShift. There are therefore some things already done:
- Folder permissions are automatically adapted with
fix-permissions
, so this image will work with a random user, and therefore also on OpenShift. - To keep
drupal.conf
's configuration file as clean and customizable as possible, we addedinclude
directives in the main sections of the file:server
,location /
,location @drupal
andlocation @php
. - Further information in the section Drupal.conf customization.
Included Nginx Drupal configuration (drupal.conf
)¶
The image includes a full Nginx working configuration for Drupal 7 and 8. It includes some extra functionalities like:
- Support for
humanstxt
Drupal module. - Support for
robotstxt
Drupal module. - Disallow access to
vagrant
directory for local development.
Drupal.conf customization¶

The drupal.conf
file is a customized version of the Nginx
configuration file, optimized for Drupal. Customers have different ways of customizing it:
- Modifying it (hard to support in case of errors).
- Using built-in customization through
*.conf
files.
The drupal.conf
file is divided into several sections. The sections we've included in our customizations are:
Codeigniter Nginx
server
location /
location @drupal
location @php
.
For each of this section, there are two includes:
*_prepend.conf
*_append.conf
Drupal Nginx Reverse Proxy
Here what the location @drupal
section looks like:
This configuration allows customers to create files called location_drupal_prepend.conf
and location_drupal_append.conf
, where they can put all the configuration they want to insert before and after the other statements.
Drupal On Nginx
Those files, once created, MUST exist in the Nginx
container, so add them to Dockerfile.nginx
like so: