Spring Redirect Command Redirects to Localhost under Load Balancer
<p>I have a Java web app built with Spring MVC running on Tomcat proxied with Apache Httpd running on an EC2 instance at AWS and configured a load balancer with SSL.</p>

<p>The request </p>

<blockquote>
  <p><a href="https://some_domain/first_uri" rel="nofollow">https://some_domain/first_uri</a></p>
</blockquote>

<p>first goes to load-balancer, load-balancer redirects the connection to Apache as (https to http because SSL is configured for the load-balancer) </p>

<blockquote>
  <p><a href="http://some_domain/first_uri" rel="nofollow">http://some_domain/first_uri</a></p>
</blockquote>

<p>Apache redirects to the localhost (Tomcat). </p>

<p>When the controller for "<em>/first_uri</em>" makes a redirect like </p>

<blockquote>
  <p>redirect:<a href="https://sub.some_domain/some_uri" rel="nofollow">https://sub.some_domain/some_uri</a></p>
</blockquote>

<p>I see the result at browser as </p>

<blockquote>
  <p><a href="https://localhost/first_uri" rel="nofollow">https://localhost/first_uri</a></p>
</blockquote>

<p>I just couldn't figure out what I must configure here, configure the Spring? configure the Apache HTTPD or the Load Balancer?</p>

<p>If someone faced the same issue please help.</p>

<p>Not: Also using Spring Security.</p>

<p>Not2: I just tried without SSL (using http) and the same thing happens, I think this is not related to the https usage.</p>

<p>Update: This problem may occur only where I try to redirect to a subdomain</p>