title: Springboot: redirect and reverse-proxy
body: <p>I'm having a SpringBoot and SpringMVC <strong>internal</strong> application (internal meaning hidden from the internet by a firewall) and a public authentication (OAuth2) service in the DMZ.</p>
  
  <p>I'm accessing the landing page from the from a client in the internal area.
  This page has a login button. When I press it, I'm forwarding the client to the auth server (in the DMZ), that I can access only going through a proxy.</p>
  
  <p>I tried setting the VM env variables:</p>
  
  <p><code>-Dhttp.proxyHost=xx -Dhttp.proxyPort=yy -Dhttp.proxySet=true</code></p>
  
  <p>and setting them in the <code>System.properties</code> </p>
  
  <pre><code>System.setProperty("http.proxyHost", "http://xx");
  System.setProperty("http.proxyPort", "xx");
  System.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
  </code></pre>
  
  <p>but both with no effect.</p>
  
  <p>I also tried to define a <code>SimpleClientHttpRequestFactory</code> bean :</p>
  
  <pre><code>&lt;?xml version = "1.0" encoding = "UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:util="http://www.springframework.org/schema/util"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
     http://www.springframework.org/schema/beans/spring-beans.xsd
     http://www.springframework.org/schema/util 
     http://www.springframework.org/schema/util/spring-util.xsd"&gt;
  
      &lt;bean id="requestFactory"
          class="org.springframework.http.client.SimpleClientHttpRequestFactory"&gt;
          &lt;property name="proxy"&gt;
              &lt;bean id="proxy" class="java.net.Proxy"&gt;
                  &lt;constructor-arg&gt;
                      &lt;util:constant static-field="java.net.Proxy.Type.HTTP" /&gt;
                  &lt;/constructor-arg&gt;
                  &lt;constructor-arg&gt;
                      &lt;bean class="java.net.InetSocketAddress"&gt;
                          &lt;constructor-arg value="xx" /&gt;
                          &lt;constructor-arg value="yy" /&gt;
                      &lt;/bean&gt;
                  &lt;/constructor-arg&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>without anymore success.</p>
  
  <p><strong>Question</strong></p>
  
  <p>How can I configure Spring to proxify my redirect ?</p>
  
  <p>Thanks!</p>