title: nginx url rewrite for reverse proxy
body: <p>I have an nginx on port 80 and a tomcat on port 8080 configured as upstream.</p>
  
  <p>The war application in tomcat listen to /pwm.</p>
  
  <p>I would like to configure nginx to a reverse proxy for tomcat and rewrite the url "/" to "/pwm".</p>
  
  <p>example:
  user types "web.noc.local" in browser and nginx rewrites the url to web.noc.local/pwm and redirects to tomcat on port 8080.</p>
  
  <p>my nginx config:</p>
  
  <pre><code>upstream pwm_server  {
      server 127.0.0.1:8080 fail_timeout=0;
  }
  
  server {
      listen       80;
      server_name  web.noc.local;     
      access_log  /var/log/nginx/log/web.noc.local.access.log  main;
      error_log  /var/log/nginx/log/web.noc.local.error.log;      
      location / {
          if ($is_args != "") {  
              rewrite "^$" /pwm  break;
              expires     7d;
              proxy_pass http://pwm_server; 
          }           
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;    
          proxy_max_temp_file_size 0;     
          proxy_buffering off;
          proxy_connect_timeout 30;
          proxy_send_timeout 30;
          proxy_read_timeout 30;
          proxy_pass http://pwm_server;
      }
  }
  </code></pre>
  
  <p>now when I open the url the, nothing happens, only a blank screen.</p>
  
  <p>thx for help.</p>