@@ -525,11 +525,24 @@ HTTPS connector:
525
525
526
526
[[howto-use-tomcat-behind-a-proxy-server]]
527
527
=== Use Tomcat behind a front-end proxy server
528
- Spring Boot will automatically configure Tomcat's `RemoteIpValve` if you enable it. This
529
- allows you to transparently use the standard `x-forwarded-for` and `x-forwarded-proto`
530
- headers that most front-end proxy servers add. The valve is switched on by setting one or
531
- both of these properties to something non-empty (these are the conventional values used by
532
- most proxies, and if you only set one the other will be set automatically):
528
+ Your app might need to send 302 redirects, or render UI templates with
529
+ absolute links to itself, or hypermedia links back to itself in the
530
+ case of a RESTful service. If the app is behind a proxy, the caller
531
+ wants a link to the proxy not to the physical address of the app, so
532
+ something has to be done in the backend. Typically this is handled via
533
+ a contract with the proxy, which will add headers to tell the back end
534
+ how to construct links to itself. If the proxy adds conventional
535
+ headers (most do this out of the box) the absolute links should be
536
+ rendered correctly by default using the Tomcat server.
537
+
538
+ Spring Boot using Tomcat automatically adds a `RemoteIpValve`. This
539
+ transparently takes the standard `x-forwarded-for` and
540
+ `x-forwarded-proto` headers and uses them to change local URLs created
541
+ in the `HttpServletRequest`. You can configure the header names in
542
+ Spring Boot and the valve is switched on unless one or both of these
543
+ properties is empty. These values are the defaults and are the
544
+ conventional values used by most proxies, so you don't need to set
545
+ them unless you need different values:
533
546
534
547
[indent=0]
535
548
----
@@ -560,8 +573,12 @@ NOTE: The double backslashes are only required when you're using a properties fi
560
573
configuration. If you are using YAML, single backslashes are sufficient and a value
561
574
that's equivalent to the one shown above would be `192\.168\.\d{1,3}\.\d{1,3}`.
562
575
563
- Alternatively, you can take complete control of the configuration of the `RemoteIpValve`
564
- by configuring and adding it in a `TomcatEmbeddedServletContainerFactory` bean.
576
+ NOTE: You can trust all proxies by setting the `internal_proxies` to empty (but don't do this in production).
577
+
578
+ You can take complete control of the configuration of the
579
+ `RemoteIpValve` by switching the automatic one off (i.e. set one of
580
+ the headers to empty) and adding a new valve instance in a
581
+ `TomcatEmbeddedServletContainerFactory` bean.
565
582
566
583
567
584
0 commit comments