title: nginx sub domains reverse proxy with node.js app
body: <p>I have 3 Node.js app. Client, Admin and API. I also have sub domains: example.com, admin.example.com and api.example.com.
  I also have nginx config but it not works (in my opinion)
  when I enter api.example.com, it loads example.com's content but when I write sub domain with port, then it works: api.example.com:8081</p>
  
  <p>in client, I'm using angular.js and maybe here is problem, but I don't think so...</p>
  
  <p>this is my nginx conf: /etc/nginx/sites-avaliable/default:</p>
  
  <pre><code>server {
      listen 80;
      server_name example.com;
      rewrite ^ https://$http_host$request_uri? permanent;
  
      location / {
          proxy_pass http://127.0.0.1:443;
          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_connect_timeout 150;
          proxy_send_timeout 100;
          proxy_read_timeout 100;
          proxy_buffers 4 32k;
          client_max_body_size 8m;
          client_body_buffer_size 128k;
      }
  }
  
  server {
      listen 80;
      server_name api.example.com;
      rewrite ^ https://$http_host$request_uri? permanent;
  
      location / {
          proxy_pass http://127.0.0.1:8081;
          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_connect_timeout 150;
          proxy_send_timeout 100;
          proxy_read_timeout 100;
          proxy_buffers 4 32k;
          client_max_body_size 8m;
          client_body_buffer_size 128k;
      }
  }
  
  server {
      listen 80;
      server_name admin.example.com;
      rewrite ^ https://$http_host$request_uri? permanent;
  
      location / {
          proxy_pass http://127.0.0.1:8082;
          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_connect_timeout 150;
          proxy_send_timeout 100;
          proxy_read_timeout 100;
          proxy_buffers 4 32k;
          client_max_body_size 8m;
          client_body_buffer_size 128k;
      }
  }
  
  enter code here
  </code></pre>