title: X-Forwarded-Host vs. x-Forwarded-Server
body: <p>What is the difference between the following headers?</p>
  
  <ul>
  <li>X-Forwarded-Host</li>
  <li>X-Forwarded-Server</li>
  </ul>
  
  <p>In a setup with Apache being the proxy and Tomcat the origin server I see both of them in the HTTP requests that reach Tomcat. Values were (this is from my own code logging the header name and value pairs with the actual capitalization I encountered)</p>
  
  <pre><code>x-forwarded-host some-server
  x-forwarded-server some-server.dept.some-uni.edu
  </code></pre>
  
  <p>Are the above values typical? Which of the two should I use to reliably reconstruct the URL asked by the browser? In my case, the browser sent a GET with the <code>some-server.dept.some-uni.edu</code> value in the request URL which leads me to think that the <code>x-forwarded-server</code> is more relevant to reconstruct the URL. I find this somewhat at odds with the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host" rel="noreferrer">MDN documentation</a> only mentioning <code>X-Forwarded-Host</code> and stating that this is the "de-facto standard header for identifying the original host requested by the client" (and containing no documentation on <code>X-Forwarded-Server</code>)</p>
  
  <p><a href="https://httpd.apache.org/docs/2.4/mod/mod_proxy.html" rel="noreferrer">This Apache page</a> OTOH describes both headers as follows:</p>
  
  <ul>
  <li><b>X-Forwarded-Host</b> The original host requested by the client in the
  Host HTTP request header.</li>
  <li><b>X-Forwarded-Server</b> The hostname of the
  proxy server.</li>
  </ul>
  
  <p>(I appreciate that to reconstruct the URL I also need <code>X-Forwarded-Proto</code> and <code>X-Forwarded-Port</code>)</p>