diff --git a/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java index ee3564d8dc..707e41e4df 100644 --- a/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java @@ -183,7 +183,9 @@ public class RequestHandler { } boolean forceHttpSession = "true".equals(context.getInitParameter("forceHttpSession")); // Check if we SHOULD be secure and are not. - if (!request.isSecure() && requestMap.securityHttps) { + String forwardedProto = request.getHeader("X-Forwarded-Proto"); + boolean isForwardedSecure = UtilValidate.isNotEmpty(forwardedProto) && "HTTPS".equals(forwardedProto.toUpperCase()); + if ((!request.isSecure() && !isForwardedSecure) && requestMap.securityHttps) { // If the request method was POST then return an error to avoid problems with XSRF where the request may have come from another machine/program and had the same session ID but was not encrypted as it should have been (we used to let it pass to not lose data since it was too late to protect that data anyway) if (request.getMethod().equalsIgnoreCase("POST")) { // we can't redirect with the body parameters, and for better security from XSRF, just return an error message