Back to top

Update your Nginx config to support Drupal 8

If you are running Drupal 7 on Nginx, the good news is that your existing Nginx configuration is almost fully compatible with hosting Drupal 8. Except one thing: Drupal 8 Update module has been re-implemented, and your existing Nginx configuration will probably return 404. For more details on Drupal 8 Update module change, please see Move update.php back to a front controller.

The change matters to Nginx config is that Drupal 7 update.php URL is like

/update.php?op=info or /update.php?op=selection

while Drupal 8 update.php URL pattern is like

/update.php/selection or /update.php/result

So, what we need to change in the existing configuration is very simple. Look for your matching condition like

location ~ \.php$ {...}

then, change it to

location ~ \.php$|^/update.php {...}

This change is adding a new case to tell Nginx, if you run into update.php on the root level, just pass it to your upstream.

I have updated my Nginx template for running Drupal 7 and Drupal 8, you can see it to look at the full picture.


Additional configuration changes also required


Thanks for the very informative blog post; it was very helpful in getting my Nginx configuration up-to-date and working with Drupal 8. In the process, I discovered a couple more configuration changes that are also required in order for everything to work right. I described the applicable symptoms and their fixes in my blog post; some of these changes should also be applied to your Nginx template (c.f. [1] and [2]). The Drupal recipe in the Nginx documentation is now up-to-date for Drupal 8, including the fix from this blog. Thanks again for writing this up!

Access denied


Thanks for the update for Nginx configuration for Drupal 8. I have created the vhost as per the above mentioned changes and restarted the nginx. On the selection page it is providing error as Access denied. /update.php/selection

Would you please help me with this?



I'm sorry to trouble you.
And if nginx is installed in the vagrant environment, what about the config in this case?