title: Spring MVC flash attributes Amazon EC2 Apache mod_proxy
body: <p>I'm using Spring MVC 4.1.6.RELEASE version for my project. I have couple of flash attributes for different scenarios on login, register and forgot password pages which are accessed prior to user logging in. The application runs perfectly fine on my localhost which is a mac with Wildfly 8.2 version.</p>
  
  <p><strong>The Problem:</strong>
  I have created an Amazon EC2 instance with RHEL version 7 (64-bit) and installed and configured the exact version of Wildfly with same JDK. None of the flash attributes show up for register and forgot password scenarios. However, any form submission errors on the same pages show up just fine. Another weird thing to note is, once logged in, any and all flash messages show up just fine.</p>
  
  <p><strong>Research:</strong>
  This is the closest issue I have found which seems to be "//" error and I have already made sure that is not the case:
  <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1072604" rel="nofollow noreferrer">https://bugzilla.redhat.com/show_bug.cgi?id=1072604</a></p>
  
  <p>Any guidance is much appreciated!</p>
  
  <p><strong>Update:</strong>
  The one difference between my local and Amazon setup is Apache. I have setup Apache on amazon ec2. Hopefully someone can throw some light as I'm still at loss.</p>
  
  <p><strong>Update 2:</strong>
  After updating I started researching with Apache and found the issue (see link below) which is exactly what my issue is BUT I'm not sure how to solve mine, yet.</p>
  
  <p><a href="https://stackoverflow.com/questions/19367531/springs-flashattributes-dont-work-behind-a-reverse-proxy">Spring&#39;s flashAttributes don&#39;t work behind a reverse proxy</a></p>
  
  <p><strong>Update 3:</strong>
  After more trial and errors I figured out that flash attributes work just fine if I access the website using the static-ip like http:// xx.xx.xx.xxx:8080/context-root/forgot-password but doesn't work when i use the domain name - http:// www.domainname.com/context-root/forgot-password.</p>
  
  <p>I have provided my existing configuration. Any mod_proxy experts, please help. </p>
  
  <p><strong>Hosting:</strong>
  2 A records</p>
  
  <p>@    12.34.56.789 -- this is the static ip for Amazon EC2</p>
  
  <p>www  12.34.56.789 -- this is the static ip for Amazon EC2</p>
  
  <p><strong>Apache Configuration</strong></p>
  
  <p>/etc/apache/httpd/conf/httpd.conf</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  ServerName 111.22.33.44 # this is local address of ec2.
  ProxyPreserveHost On   
  ProxyRequests Off
  
  &lt;Proxy *&gt;  
      Order deny,allow
      Allow from all
  &lt;/Proxy&gt;   
  
  ProxyPass /context-root http://111.22.33.44:8080/&lt;context-root&gt;/
  ProxyPassReverse /context-root http://111.22.33.44:8080/&lt;context-root&gt;/
  
  ProxyPass / http://111.22.33.44:8080/&lt;context-root&gt;/
  ProxyPassReverse / http://111.22.33.44:8080/&lt;context-root&gt;/
  &lt;/VirtualHost&gt; 
  </code></pre>
  
  <p><strong>Wildfly Configuration: standalone.xml</strong></p>
  
  <pre><code>&lt;interfaces&gt;
      &lt;interface name="management"&gt;
          &lt;inet-address value="${jboss.bind.address.management:127.0.0.1}"/&gt;
      &lt;/interface&gt;
      &lt;interface name="public"&gt;
          &lt;inet-address value="${jboss.bind.address:127.0.0.1}"/&gt;
      &lt;/interface&gt;
      &lt;interface name="unsecure"&gt;
          &lt;inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/&gt;
      &lt;/interface&gt;
      &lt;interface name="external"&gt;
          &lt;nic name="eth0"/&gt;
      &lt;/interface&gt;
  &lt;/interfaces&gt;
  
  &lt;socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}"&gt;
      &lt;socket-binding name="management-http" interface="external" port="${jboss.management.http.port:9990}"/&gt;
      &lt;socket-binding name="management-https" interface="external" port="${jboss.management.https.port:9993}"/&gt;
      &lt;socket-binding name="ajp" interface="external" port="${jboss.ajp.port:8009}"/&gt;
      &lt;socket-binding name="http" interface="external" port="${jboss.http.port:8080}"/&gt;
      &lt;socket-binding name="https" interface="external" port="${jboss.https.port:8443}"/&gt;
      &lt;socket-binding name="txn-recovery-environment" port="4712"/&gt;
      &lt;socket-binding name="txn-status-manager" port="4713"/&gt;
      &lt;outbound-socket-binding name="mail-smtp"&gt;
          &lt;remote-destination host="localhost" port="25"/&gt;
      &lt;/outbound-socket-binding&gt;
  &lt;/socket-binding-group&gt;
  </code></pre>
  
  <p><strong>Headers as requested by Brian</strong></p>
  
  <p><strong>These are the headers when i use static ip, flash attributes work in this scenario</strong></p>
  
  <pre><code>Response Headers
  
  Cache-Control   no-cache, no-store, max-age=0, must-revalidate  
  Connection  keep-alive  
  Content-Language    en-US  
  Content-Length  0  
  Date    **removed**  
  Expires 0  
  Location    http:// 12.34.56.789:8080/context-root/forgot  
  Pragma  no-cache  
  Server  WildFly/8  
  X-Powered-By    Undertow/1  
  x-content-type-options  nosniff  
  x-frame-options DENY  
  x-xss-protection    1; mode=block
  
  Request Headers
  
  Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
  Accept-Encoding gzip, deflate  
  Accept-Language en-US,en;q=0.5  
  Connection  keep-alive  
  Cookie  JSESSIONID=pH25lMW0Rg3HKK1iXxVKIl1O.ip-111-22-33-44   
  Host    12.34.56.789:8080  
  Referer http:// 12.34.56.789:8080/context-root/forgot  
  Upgrade-Insecure-Requests   1  
  User-Agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0)   
  Gecko/20100101 Firefox/49.0
  
  Request Headers from upload stream
  
  Content-Length  92  
  Content-Type    application/x-www-form-urlencoded
  </code></pre>
  
  <p><strong>These are the headers when i use domain name, flash attributes don't work</strong>  </p>
  
  <pre><code>Response Headers   
  Cache-Control   no-cache, no-store, max-age=0, must-revalidate  
  Connection  Keep-Alive  
  Content-Language    en-US  
  Content-Length  0  
  Date    **removed**  
  Expires 0  
  Keep-Alive  timeout=5, max=100  
  Location    http:// www.domain-name/context-root/forgot  
  Pragma  no-cache  
  Server  WildFly/8  
  X-Powered-By    Undertow/1  
  x-content-type-options  nosniff  
  x-frame-options DENY  
  x-xss-protection    1; mode=block  
  
  Request Headers  
  Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
  Accept-Encoding gzip, deflate  
  Accept-Language en-US,en;q=0.5  
  Connection  keep-alive  
  Cookie  JSESSIONID=4-DUMB5f1U7eTDcNePYUAy8c.ip-111-22-33-44  
  Host    www.domain-name  
  Referer http:// www.domain-name/context-root/forgot  
  Upgrade-Insecure-Requests   1  
  User-Agent  Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0)  Gecko/20100101 Firefox/49.0
  
  Request Headers from upload stream  
  Content-Length  92  
  Content-Type    application/x-www-form-urlencoded
  </code></pre>