I would like to have an external file and import it to site configuration (*.conf).

In this external file, I need to put some variables and use then in the site conf.

variable file (psoudo code):

set $domain site.com

in site.conf

import 'variables.conf'

server {
    listen 80;
    server_name $domain;
...... the rest of the file

update I have several environments and I want to deploy with some variables because 98% if the config is the same for all environments and I want to use the 2% with variables.


  • You can’t use variables in server_name. So for now the question is pointless – Alexey Ten Sep 8 '19 at 13:10
  • Describe the problem you want to solve. – Alexey Ten Sep 8 '19 at 13:12
  • @AlexeyTen I have added that to my question. thanks – SexyMF Sep 8 '19 at 13:20
  • 1
    Better to use some external templating tool or even bash/python/whatever script to generate nginx config. – Alexey Ten Sep 8 '19 at 13:24
  • Right, this should be generated by your configuration management system. – Michael Hampton Sep 8 '19 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.