title: How to create single NGINX.conf file for multiple environment
body: <p>I using NGINX as a reverse proxy.</p>
  
  <p>I have 3 environments <strong>(develop, QA, production)</strong> </p>
  
  <p>Consider, The IP address for <strong>develop is 1.2.3.4, qa is 4.3.2.1 and production is 3.4.1.2</strong></p>
  
  <p>I have configure the nginx.conf file as below and its working perfectly fine in case of <strong>develop</strong> environment.</p>
  
  <p>While building these docker-image I have explisitly mention on which configuraton the image should be build as below</p>
  
  <pre><code>cd conf/clustered-develop/;sudo docker build -t jcibts-swmdtr-dev.jci.com/nginx:1 --build-arg PORT=8765 --build-arg ENVIRONMENT=clustered-develop .
  </code></pre>
  
  <p>The requirement is docker-image should be build only 1's and then it will be push to Docker Trusted repository. </p>
  
  <p>It will be promoted to other environment's docker trusted repository without building the image again.</p>
  
  <p>MY question is what can I do to work these single conf for all the environment.</p>
  
  <p>Like ip replaced by localhost or ip replaced by 127.0.0.1 (I have tried both but not working)</p>
  
  <pre><code>worker_processes 4;
  
  events { worker_connections 1024; }
  http {
  
      sendfile on;
  
      upstream consumer-portal {
  
          server 1.2.3.4:9006;
  
      }
  
      upstream licenseportal {
  
          server 1.2.3.4:9006;
  
      }
  
  server {
          listen 8765;
  
          location /consumer-portal/ {
              proxy_pass         http://consumer-portal/;
              proxy_redirect     off;
              proxy_set_header   Host $host;
              proxy_set_header   X-Real-IP $remote_addr;
              proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header   X-Forwarded-Host $server_name;
          }
  
          location /licenseportal/ {
              proxy_pass         http://licenseportal/;
              proxy_redirect     off;
              proxy_set_header   Host $host;
              proxy_set_header   X-Real-IP $remote_addr;
              proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header   X-Forwarded-Host $server_name;
          }
   }
  
  
  }
  </code></pre>