Customizing Nginx

Nitro is no longer supported. Please see our announcement and DDEV migration guide.

Nitro 2 includes a limited ability to customize a site’s nginx configuration.

You can include a file with any name ending in nitro.conf in the root of your project directory to have Nitro pull its nginx configuration when running the apply command. (If you’ve added the file to an already-running site, delete the container and run nitro apply again to have it rebuilt.)

The caveat here is that Nitro may override some of your location statements with its own. This means Nitro will favor anything nginx configuration that comes after this line (opens new window) and additional included files like this one (opens new window).

So you could add your own new location like this...

location ~ ^/testing {
    default_type text/html;
    return 200 'Testing custom config!';
}

...but you could not adjust the location / directive that hands most URLs off to index.php like this example (opens new window) from the Blitz plugin’s documentation.

This is a known limitation of Nitro 2, and Nitro 3 will support full control over a site’s nginx configuration.