title: Make Spring Boot Actuator aware of X-Forwarded-Prefix header?
body: <p>We're using Spring Boot 2.7.0 with <code>spring-boot-starter-actuator</code> that we're exposing on port 8081 under the <code>/management</code> context path. The proxy sets several <code>X-Forwarded-*</code> headers, including the <code>X-Forwarded-Prefix</code> header that is set to <code>/service</code>. But when navigating to <code>https://www.company.com/management</code> this is what is returned:</p>
  <pre><code>{
      &quot;_links&quot;: {
          &quot;self&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management&quot;,
              &quot;templated&quot;: false
          },
          &quot;beans&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/beans&quot;,
              &quot;templated&quot;: false
          },
          &quot;caches-cache&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/caches/{cache}&quot;,
              &quot;templated&quot;: true
          },
          &quot;caches&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/caches&quot;,
              &quot;templated&quot;: false
          },
          &quot;health&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/health&quot;,
              &quot;templated&quot;: false
          },
          &quot;health-path&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/health/{*path}&quot;,
              &quot;templated&quot;: true
          },
          &quot;info&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/info&quot;,
              &quot;templated&quot;: false
          },
          &quot;conditions&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/conditions&quot;,
              &quot;templated&quot;: false
          },
          &quot;configprops&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/configprops&quot;,
              &quot;templated&quot;: false
          },
          &quot;configprops-prefix&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/configprops/{prefix}&quot;,
              &quot;templated&quot;: true
          },
          &quot;env&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/env&quot;,
              &quot;templated&quot;: false
          },
          &quot;env-toMatch&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/env/{toMatch}&quot;,
              &quot;templated&quot;: true
          },
          &quot;integrationgraph&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/integrationgraph&quot;,
              &quot;templated&quot;: false
          },
          &quot;loggers&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/loggers&quot;,
              &quot;templated&quot;: false
          },
          &quot;loggers-name&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/loggers/{name}&quot;,
              &quot;templated&quot;: true
          },
          &quot;heapdump&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/heapdump&quot;,
              &quot;templated&quot;: false
          },
          &quot;threaddump&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/threaddump&quot;,
              &quot;templated&quot;: false
          },
          &quot;metrics-requiredMetricName&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/metrics/{requiredMetricName}&quot;,
              &quot;templated&quot;: true
          },
          &quot;metrics&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/metrics&quot;,
              &quot;templated&quot;: false
          },
          &quot;scheduledtasks&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/scheduledtasks&quot;,
              &quot;templated&quot;: false
          },
          &quot;sessions-sessionId&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/sessions/{sessionId}&quot;,
              &quot;templated&quot;: true
          },
          &quot;sessions&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/sessions&quot;,
              &quot;templated&quot;: false
          },
          &quot;mappings&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/mappings&quot;,
              &quot;templated&quot;: false
          },
          &quot;refresh&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/refresh&quot;,
              &quot;templated&quot;: false
          },
          &quot;features&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/features&quot;,
              &quot;templated&quot;: false
          },
          &quot;traces&quot;: {
              &quot;href&quot;: &quot;https://www.company.com/management/traces&quot;,
              &quot;templated&quot;: false
          }
      }
  }
  </code></pre>
  <p>I'm expecting the href's in the response to start with <code>https://www.company.com/service</code> due to the supplied <code>X-Forwarded-Prefix</code> header, but this is not the case. I've tried to add the <code>ForwardedHeaderFilter</code> like this:</p>
  <pre><code>@Bean
  public FilterRegistrationBean&lt;ForwardedHeaderFilter&gt; forwardedHeaderFilterFilterRegistrationBean() {
      ForwardedHeaderFilter forwardedHeaderFilter = new ForwardedHeaderFilter();
      FilterRegistrationBean&lt;ForwardedHeaderFilter&gt; bean = new FilterRegistrationBean&lt;&gt;(forwardedHeaderFilter);
      bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
      return bean;
  }
  </code></pre>
  <p>but it makes no difference.</p>
  <p>How can I make actuator take the <code>X-Forwarded-Prefix</code> header into account when generating the links to the endpoints behind a proxy?</p>