title: How do I reliably access the HttpServletRequest in a jspx when it's behind a proxy?
body: <p>I've got a jspx that needs to know the current <code>HttpServletRequest</code>'s <code>getServerName()</code>.   The jspx can fetch this with <code>#{mybean.serverName}</code> from its bean, like this:</p>
  
  <pre><code>public String getServerName() {
    HttpServletRequest request = (HttpServletRequest) FacesInstance.getCurrentInstance().getExternalContent().getRequest();
    return request.getServerName();
  }
  </code></pre>
  
  <p>However, when this is served behind a proxy (Apache with mod_proxy), <code>getServerName()</code> will <em>some times</em> return the node's host name instead of the frontend's host name.  Other times it works correctly.</p>
  
  <p>A plain jsp with <code>&lt;% request.getServerName(); %&gt;</code> will, however, always return the frontend's host name.</p>
  
  <p>What's the problem with FacesInstance's <code>HttpServletRequest</code>?  Is there a way to fetch the "real" request object?</p>