Add Custom nginx Configuration under Aegir 2

Your case may vary, but I had the following situation;

Customer has a monitoring solution, Monitorix, which they want to be available under their aegir host. Sure you can add the lines to the ~aegir/config/server_master/nginx/vhosts.d/, but every time the hostmaster site is verified, you will have to re-add the necessary config lines. What a pain in the ass.

A better way is to create a custom drush module, containing the correct hook.

Here’s my ~aegir/.drush/

Don’t forget to chmod +x ~aegir/.drush/ so that Drush will be able to run your module

A few gotchas;

  • Line 3: You must begin your function name with the same string that you started the drush file as.  In my case, I used kit. You can use something equally as cool.
  • Line 3: If you’re using Apache instead of nginx, you should alter the function name and replace nginx with apache.
  • Line 4: You should change to your aegir host.

Now, when a site is verified, and it’s hostname is, the module will return the array containing the necessary config lines, which is then added to the config files located in ~aegir/config/server_master/nginx/vhosts.d/

Leave a Reply

Your email address will not be published. Required fields are marked *