title: configure nginx for nodejs and elasticsearch on one server
body: <p>I am using nginx as web/proxy server for my website build using MEAN stack.
  So the configuration file for nginx looks like</p>
  
  <pre><code>    server {  
          listen 80;
          server_name www.domainname.com;
          location / {
              proxy_pass http://localhost:3000;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection 'upgrade';
              proxy_set_header Host $host;
              proxy_cache_bypass $http_upgrade;
          }
  
            location /blog {
              proxy_pass http://localhost:2368;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection 'upgrade';
              proxy_set_header Host $host;
              proxy_cache_bypass $http_upgrade;
          }
  }
  </code></pre>
  
  <p>Node server is running on port 3000 and my blog is running on 2368.This setup is running fine.</p>
  
  <p>Now I have included elasticsearch also in the same aws server which is listening to port 9200.I want to make changes in nginx config.</p>
  
  <p>Can someone please help me with the change to include elasticsearch also.I had already tried to include below code but it is not working</p>
  
  <pre><code>server {
      listen 9200;
      server_name www.domainname.com;
      location / {
          rewrite ^/(.*) /$1 break;
          proxy_ignore_client_abort on;
          proxy_pass http://localhost:9200;
          proxy_redirect http://localhost:9200 http://www.domainname.com:9200/;
          proxy_set_header  X-Real-IP  $remote_addr;
          proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header  Host $http_host;
  
  }
  }
  </code></pre>