(window.webpackJsonp=window.webpackJsonp||[]).push([[521],{949:function(t,e,r){"use strict";r.r(e);var a=r(56),o=Object(a.a)({},(function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("ContentSlotsDistributor",{attrs:{"slot-key":t.$parent.slotKey}},[r("h1",{attrs:{id:"http"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#http"}},[t._v("#")]),t._v(" HTTP")]),t._v(" "),r("p",[t._v("所有基于 HTTP 的通信,包括"),r("a",{attrs:{href:"https://www.troyhunt.com/heres-why-your-static-website-needs-https/",target:"_blank",rel:"noopener noreferrer"}},[t._v("静态资源"),r("OutboundLink")],1),t._v(",都应该受到"),r("a",{attrs:{href:"https://cheatsheetseries.owasp.org/cheatsheets/Transport_Layer_Protection_Cheat_Sheet.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("using TLS"),r("OutboundLink")],1),t._v("的保护。")]),t._v(" "),r("p",[t._v("作为一个框架, Spring 安全性不处理 HTTP 连接,因此不直接提供对 HTTPS 的支持。然而,它确实提供了许多有助于 HTTPS 使用的功能。")]),t._v(" "),r("h2",{attrs:{id:"重定向到-https"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#重定向到-https"}},[t._v("#")]),t._v(" 重定向到 HTTPS")]),t._v(" "),r("p",[t._v("当客户端使用 HTTP 时, Spring 安全性可以被配置为将"),r("RouterLink",{attrs:{to:"/servlet/exploits/http.html#servlet-http-redirect"}},[t._v("Servlet")]),t._v("和"),r("RouterLink",{attrs:{to:"/reactive/exploits/http.html#webflux-http-redirect"}},[t._v("WebFlux")]),t._v("环境重定向到 HTTPS。")],1),t._v(" "),r("h2",{attrs:{id:"严格的运输安全"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#严格的运输安全"}},[t._v("#")]),t._v(" 严格的运输安全")]),t._v(" "),r("p",[t._v("Spring 安全性为"),r("RouterLink",{attrs:{to:"/spring-security/headers.html#headers-hsts"}},[t._v("严格的运输安全")]),t._v("提供支持,并在默认情况下启用它。")],1),t._v(" "),r("h2",{attrs:{id:"代理服务器配置"}},[r("a",{staticClass:"header-anchor",attrs:{href:"#代理服务器配置"}},[t._v("#")]),t._v(" 代理服务器配置")]),t._v(" "),r("p",[t._v("在使用代理服务器时,重要的是要确保你已经正确地配置了应用程序。例如,许多应用程序将有一个负载均衡器,该负载均衡器通过在"),r("a",{attrs:{href:"https://192.168.1:8080",target:"_blank",rel:"noopener noreferrer"}},[t._v("https://192.168.1:8080"),r("OutboundLink")],1),t._v("处将请求转发到应用程序服务器来响应"),r("a",{attrs:{href:"https://example.com/",target:"_blank",rel:"noopener noreferrer"}},[t._v("https://example.com/"),r("OutboundLink")],1),t._v("的请求。如果没有适当的配置,应用程序服务器将不知道负载均衡器的存在,并将请求视为"),r("a",{attrs:{href:"https://192.168.1:8080",target:"_blank",rel:"noopener noreferrer"}},[t._v("https://192.168.1:8080"),r("OutboundLink")],1),t._v("是由客户机请求的。")]),t._v(" "),r("p",[t._v("要解决这个问题,你可以使用"),r("a",{attrs:{href:"https://tools.ietf.org/html/rfc7239",target:"_blank",rel:"noopener noreferrer"}},[t._v("RFC 7239"),r("OutboundLink")],1),t._v("来指定正在使用负载均衡器。要使应用程序意识到这一点,你需要配置你的应用程序服务器来了解 X 转发头。例如, Tomcat 使用"),r("a",{attrs:{href:"https://tomcat.apache.org/tomcat-8.0-doc/api/org/apache/catalina/valves/RemoteIpValve.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("Remoteipvalve"),r("OutboundLink")],1),t._v(", Jetty 使用"),r("a",{attrs:{href:"https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/server/ForwardedRequestCustomizer.html",target:"_blank",rel:"noopener noreferrer"}},[t._v("ForwardeDrequestCustomizer"),r("OutboundLink")],1),t._v("。或者, Spring 用户可以利用"),r("a",{attrs:{href:"https://github.com/spring-projects/spring-framework/blob/v4.3.3.RELEASE/spring-web/src/main/java/org/springframework/web/filter/ForwardedHeaderFilter.java",target:"_blank",rel:"noopener noreferrer"}},[t._v("ForwardedHeaderFilter"),r("OutboundLink")],1),t._v("。")]),t._v(" "),r("p",[t._v("Spring 引导用户可以使用"),r("code",[t._v("server.use-forward-headers")]),t._v("属性来配置应用程序。有关更多详细信息,请参见"),r("a",{attrs:{href:"https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-use-tomcat-behind-a-proxy-server",target:"_blank",rel:"noopener noreferrer"}},[t._v("Spring Boot documentation"),r("OutboundLink")],1),t._v("。")])])}),[],!1,null,null,null);e.default=o.exports}}]);