Jump to content

"global" nginx configuration


Go to solution Solved by Jacques1,

Recommended Posts

Hi all

 

I have about 150 virtual hosts configured in nginx.
these hosts all have the same configuration with exception of the domain name, and the paths for said domain.

 

each time I need to change a setting on one of the hosts, I need to replicate the change on ALL the domains.

is there a way to "include" these configurations into the server block, to prevent me from changing each block?

 

It needs to be includable cause there are other virtual hosts that deviate from the normal. and do not need those configurations.

 

Thanks for any advice

Link to comment
https://forums.phpfreaks.com/topic/301189-global-nginx-configuration/
Share on other sites

I'm not familiar enough with nginx to know if it has a built in solution to your problem, but if it doesn't, then an alternative is to use some sort of build and template system outside of nginx to generate the configuration file.

 

For example, you could use a simple PHP script and the Twig template engine to run through a list of domains and generate individual configuration files for each domain based on a standard default template.

 

Whenever you need to make a change, you alter the template then re-generate the configuration files by running the PHP script and then reload nginx.

  • Like 1
  • Solution

nginx has the include directive which does exactly what the name says. I'm surprised you couldn't find it, Darghon.

 

Many settings can also be declared at the top level rather than per server block. This makes life even easier, because the values are automatically inherited but can still be overriden whenever needed.

 

What are those global settings, anyway?

Edited by Jacques1
  • Like 1

All the advice you've been given is correct.

 

Nginx will never have config variables, as the developers have been clear that they don't believe that the performance cost of parsing and compiling configuration is acceptable.

 

Jacques already linked you the include directive page.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.