Darghon Posted May 15, 2016 Share Posted May 15, 2016 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 Quote Link to comment Share on other sites More sharing options...
benanamen Posted May 15, 2016 Share Posted May 15, 2016 Apache server is already set up that way with a separate file that is included for each virtual host. Any reason you can't use apache? Not familiar with nginx config. Quote Link to comment Share on other sites More sharing options...
kicken Posted May 15, 2016 Share Posted May 15, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
Solution Jacques1 Posted May 15, 2016 Solution Share Posted May 15, 2016 (edited) 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 May 15, 2016 by Jacques1 1 Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 17, 2016 Share Posted May 17, 2016 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.