1

I have a development environment with a simple Debian image whilst I also use a Jetware EC2 optimised Debian image for my staging environment.

The Jetware filesystem is mounted under the /jet, hence I have slight changes between my nginx.conf et vhost files, ex:

pid /run/nginx/nginx.pid; vs pid /jet/run/nginx/nginx.pid;

Or also include /jet/etc/nginx/mime.types; vs include /jet/etc/nginx/mime.types;

Is there a server_root directive of sort that I could add to my nginx.conf configuration, to keep the changes between files minimal ?

0

It turns out that the approach (initiating a "$filesystem_root_dir" variable at the top of the file and assigning it one value per configuration) is:

  • Not allowed (it throws the fatal: nginx: [emerg] "set" directive is not allowed here in /etc/nginx/nginx.conf:1)
  • discouraged by the Nginx team:
Variables should not be used as template macros. Variables are evaluated in the run-time during the processing of each request, so they are rather costly compared to plain static configuration. Using variables to store static strings is also a bad idea. Instead, a macro expansion and "include" directives should be used to generate configs more easily and it can be done with the external tools, e.g. sed + make or any other common template mechanism. 

http://nginx.org/en/docs/faq/variables_in_config.html

I thought about a template generator but the cost way outweight the gains, so I'll either keep the files slighlty different moving forward.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.