title: X-Forwarded-Proto https in frontend or backend (HAProxy)?
body: <p>I have setup a HAProxy in front of my backend server application to enable HTTPS. I have read that I need to set <code>X-Forward-Proto https</code>.</p>
  
  <p>In the <strong>haproxy.cfg</strong> file I have tried to do that in the <strong>frontend</strong> with:</p>
  
  <pre><code>frontend haproxy
    bind :8443 ssl crt frontend/server.pem
    reqadd X-Forwarded-Proto:\ https
    default_backend my-backend
  </code></pre>
  
  <p>and that seems to make it work - e.g. I can both login to my backend server and navigate to the different pages. If I DON'T have the proto option I can only login but not navigate to any other pages.</p>
  
  <p>Now I if add the option in the <strong>backend</strong> instead (removing it from the front end) with:</p>
  
  <pre><code>backend my-backend
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    server my-backend 127.0.0.1:9000
  </code></pre>
  
  <p>it also works, I can navigate the different pages in my backend server application.</p>
  
  <p>So which is the correct way to do it? In the frontend or in the backend or does it not matter?</p>