title: How to load balance using Nginx?
body: <p>I am using <a href="https://www.digitalocean.com/community/articles/how-to-set-up-nginx-load-balancing" rel="nofollow">this tutorial</a> but instead of plain server:port I am specifying app directory, but it is giving the below exception </p>
  
  <pre><code>nginx: [emerg] invalid host in upstream "localhost:9090/pa" in C:\app\abhishek\nginx_test\nginxc1/conf/nginx.conf:18
  </code></pre>
  
  <p>I am using nginx as my load balance and tomcat as my webserver. I am able to access my tomcat webapp using <code>http://localhost:9090/pa</code> and <code>http://localhost:10080/pa</code>.</p>
  
  <p>Here is my nginx.conf file</p>
  
  <pre><code>#user  nobody;
  worker_processes  1;
  
  error_log  logs/error.log  info;
  
  events {
      worker_connections  1024;
  }
  
  
  http {
  
      #keepalive_timeout  0;
      keepalive_timeout  75;
  
      upstream balancer {
          server localhost:9090/pa weight=2;
          server localhost:10080/pa;
      }
  
      server {
          listen       6789;
          server_name  localhost;
  
          location /bal/ {
              proxy_pass http://balancer;
          }
  
          error_page   500 502 503 504 404  /50x.html;
          location = /50x.html {
              root   html;
          }
  
      }
  
  }
  </code></pre>