title: How to redirect url using haproxy
body: <p>I want to redirect <a href="https://myserver/myapplication/" rel="nofollow noreferrer">https://myserver/myapplication/</a> to <a href="https://myserver.domain.com/myapplication/" rel="nofollow noreferrer">https://myserver.domain.com/myapplication/</a> using haproxy. </p>
  
  <p>This is my haproxy configuration</p>
  
  <pre><code>frontend LB_http
     bind 10.123.122.112:80
     reqadd X-Forwarded-Proto:\ http
     default_backend LB
  
  
  frontend LB_https
     bind 10.123.122.112:443 ssl crt /usr/local/apache2/conf/server.pem
     reqadd X-Forwarded-Proto:\ https
     default_backend LB
  
  backend LB
     redirect scheme https if !{ ssl_fc }
     mode http
     stats enable
     stats hide-version
     stats uri /stats
     stats realm Haproxy\ Statistics
     stats auth haproxy:redhat            # Credentials for HAProxy Statistic report page.
     balance roundrobin                   # Load balancing will work in round-robin process.
     option httpchk
     option httpclose
     option forwardfor
  
     server myserver.domain.com myserver.domain.com:80          # backend server.
  </code></pre>
  
  <p>I have edited the config file by adding the below two lines</p>
  
  <pre><code>acl no_domain hdr(host) -i myserver
  http-request redirect code 301 prefix %[hdr(host)].domain.com%[path] if no_domain
  </code></pre>
  
  <p>But now, when I try </p>
  
  <blockquote>
    <p>myserver/myapplication/</p>
  </blockquote>
  
  <p>the url is redirecting multiple times I guess. It is redirecting me to very long url like this </p>
  
  <blockquote>
    <p><a href="https://myserver/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/" rel="nofollow noreferrer">https://myserver/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/myserver.domain.com/myapplication/</a></p>
  </blockquote>
  
  <p>What am I missing?</p>