Skip to content

Nginx

You can configure Nginx via environment variables that listed at https://github.com/wodby/drupal-nginx

PHP endpoints

For security reasons, default nginx config allows executing limited php endpoints. This is how you can add addition php endpoint:

  1. Add *.conf file to your codebase with locations definition, example:
    location = /custom-php-endpoint.php {
        fastcgi_pass php;
    }
    
  2. In nginx service configuration set new environment variable NGINX_SERVER_EXTRA_CONF_FILEPATH to your *.conf file (e.g. /var/www/html/drupal.conf). It will be included at the end of /etc/nginx/conf.d/drupal.conf
  3. Restart the service

Alternatively, you can replace your HTTP server to Apache that has less strict rules.

XML endpoints

By default nginx config requests Drupal backend when rss.xml or sitemap.xml requested. If you want to add another XML endpoint generated by Drupal just set environment variable NGINX_ALLOW_XML_ENDPOINTS to any value and restart the service.

Additional configuration

If the default drupal config and available environment variables are not enough for your customizations you can replace the config with your own:

  1. Copy /etc/nginx/conf.d/drupal.conf to your codebase, adjust to your needs
  2. Deploy code with your config file
  3. Add new environment variable NGINX_CONF_INCLUDE for nginx service, the value should the path to your *.conf file (e.g. /var/www/html/nginx.conf

Files proxy

You can proxy all requests to files to (similar to what drupal module stage_file_proxy does) by adding the environment variable NGINX_DRUPAL_FILE_PROXY_URL to URL of your Drupal instance with files, e.g. http://example.com