title: HAProxy - URL redirection & rewriting
body: <p>I am completely new to haproxy setup. I want to setup haproxy on top of tomcat servers.</p>
  
  <p>The below configuration works well for tomcat applications.</p>
  
  <pre><code>global
      log 127.0.0.1   local0
      log 127.0.0.1   local1 notice
      maxconn 4096
      user haproxy
      group haproxy
  
  defaults
  
      log     global
      mode    http
      option  httplog
      option  dontlognull
      retries 3
      option redispatch
      maxconn 20000
      contimeout      5000
      clitimeout      50000
      srvtimeout      50000
  
  listen webfarm 100.100.100.100:80
     mode http
     stats enable
     stats uri /haproxy?statis
     stats realm Haproxy\ Auth
     stats auth user:password
     balance leastconn
     cookie JSESSIONID insert indirect nocache
     option httpclose
     option forwardfor
     server web01 192.168.1.1:8080 cookie A check
     server web02 192.168.1.2:8080 cookie B check
  </code></pre>
  
  <p>But i dont want user to enter the complete url. so when a user hits web1.example.com it need to server application from a tomcat webapp directory. Also i dont want the url changed.</p>
  
  <pre><code>Example : http://web1.example.com -&gt; http://192.168.1.1:8080/applications/web1 &amp; http://192.168.1.2:8080/applications/web1
  </code></pre>
  
  <p>Is this possible with a url redirection and url rewriting? If yes please help me with a sample configuration.</p>
  
  <p>Any help will be really appreciated.</p>
  
  <p>Thanks</p>