title: nginx won't restart with my config file
body: <p>Restarting nginx : </p>
  
  <pre><code># service nginx start
  Starting nginx: nginx: [emerg] duplicate upstream "api" in /etc/nginx/sites-enabled/default:1
  nginx: configuration file /etc/nginx/nginx.conf test failed
  </code></pre>
  
  <p>This is the config file : </p>
  
  <pre><code>upstream api{
          least_conn;
          server 127.0.0.1:5001 max_fails=2 fail_timeout=15s;
          server 127.0.0.1:5002 max_fails=2 fail_timeout=15s;
          server 127.0.0.1:5003 max_fails=2 fail_timeout=15s;
          server 127.0.0.1:5004 max_fails=2 fail_timeout=15s;
  }
  
  
  server {
          listen 192.168.10.33:80;
          allow 192.168.0.0/20;
          allow 127.0.0.1/32;
          deny all;
  
          server_name api api.my.intranet;
          location ^~ (/images/|/css/|/javascripts/) {
                  root /var/www/myapi/public/;
                  expires 30m;
          }
  
          # serve all other stuff from appserver
          location / {
                   if ($http_origin ~ (.*\.my\.intranet|.*\.my\.com) ) {
                         add_header 'Access-Control-Allow-Origin' $http_origin;
                  }
  
                  # add_header 'Access-Control-Allow-Origin' '*';
  
                    expires off;
                    proxy_pass        http://api/;
                    proxy_set_header X-Real-IP  $remote_addr;
                    proxy_set_header Host $http_host;
                    proxy_set_header X-Forwarded-Host $http_host;
          }
  }
  
  server {
          listen 175.30.33.14:80;
          server_name api.my.com;
          return 301 https://api.my.com$request_uri;
  
  }
  
  server {
          listen 443;
          ssl on;
          ssl_certificate /etc/ssl/certs/my.com.2014.chain;
          ssl_certificate_key /etc/ssl/private/my.com.2014.key;
  
          server_tokens off; 
  
          server_name api api.my.com api.my.intranet;
          location ^~ (/images/|/css/|/javascripts/) {
                  root /var/www/myapi/public/;
                  expires 30d;
          }
          # serve all other stuff from appserver
          location / {
                   if ($http_origin ~ (.*\.my\.intranet|.*\.my\.com) ) {
                         add_header 'Access-Control-Allow-Origin' $http_origin;
                  }
                  # add_header 'Access-Control-Allow-Origin' '*';
  
                    expires off;
                    proxy_pass http://api/;
                    proxy_set_header X-Real-IP  $remote_addr;
                    proxy_set_header Host $http_host;
                    proxy_set_header X-Forwarded-Host $http_host;
          }
          location /v2 {
                  rewrite  ^/v2/(.*)  /$1 break;
                   if ($http_origin ~ (.*\.my\.intranet|.*\.my\.com) ) {
                         add_header 'Access-Control-Allow-Origin' $http_origin;
                  }
                  # add_header 'Access-Control-Allow-Origin' '*';
  
                    expires off;
                    proxy_pass        http://192.168.10.8:3000/;
                    proxy_set_header X-Real-IP  $remote_addr;
                    proxy_set_header Host $http_host;
                    proxy_set_header X-Forwarded-For $remote_addr;
          }
  }
  </code></pre>
  
  <p>Do you see any problem ? </p>