Issue
- Sometimes there are several HTTP 400 Bad Request errors with URLs from the portal.
For example, when editing a user, a bad request is shown. - In the Tomcat access log we could see the 400 request:
- | 10.172.2.11 | [10/May/2021:09:12:21 +0000] | GET | "/group/control_panel/manage" | "?p_p_id=com_liferay_users_admin_web_portlet_UsersAdminPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_com_liferay_users_admin_web_portlet_UsersAdminPortlet_mvcRenderCommandName=%2Fusers_admin%2Fedit_user&_com_liferay_users_admin_web_portlet_UsersAdminPortlet_backURL=https%3A%2F%2Fmywebsite.es%2Fgroup%2Fcontrol_panel%2Fmanage%3Fp_p_id%3Dcom_liferay_users_admin_web_portlet_UsersAdminPortlet%26p_p_lifecycle%3D0%26p_p_state%3Dmaximized%26p_p_mode%3Dview%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_toolbarItem%3Dview-all-users%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_usersListView%3Dflat-users%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_cur2%3D1%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_delta2%3D20%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_keywords%3Doscibanez%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_status%3D0%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_emailAddress%3D%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_firstName%3D%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_lastName%3D%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_middleName%3D%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_organizationId%3D0%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_roleId%3D0%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_screenName%3D%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_userGroupId%3D0%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_orderByCol%3Dname%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_orderByType%3Dasc%26_com_liferay_users_admin_web_portlet_UsersAdminPortlet_navigation%3D&_com_liferay_users_admin_web_portlet_UsersAdminPortlet_p_u_i_d=278699800" | 400 | - | 0 | "null" | "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
- In catalina.out we could see this trace:
10-May-2021 07:45:39.237 INFO [http-nio-8080-exec-133] org.apache.coyote.http11.AbstractHttp11Processor.process Error parsing HTTP request header
Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Request header is too large
Environment
- Liferay DXP bundled with Tomcat
Resolution
- The solution is to increase the value of
maxHttpHeaderSize
in Tomcat configuration.- Since Tomcat 9, you can also use
maxHttpRequestHeaderSize
.
- Since Tomcat 9, you can also use
- According to the Tomcat documentation:
maxHttpHeaderSize
: The maximum permitted size of the request line and headers associated with an HTTP request/response, specified in bytes. If not specified, this attribute is set to 8192 (8 KiB).
- So setting the
maxHttpHeaderSize
/maxHttpRequestHeaderSize
to a higher value resolves this. - But also be aware of the following note:
(...) Tomcat will allocate the full amount you specify for every request. For example, if you specify a maxHttpRequestHeaderSize of 1 MB and your application handles 100 concurrent requests, you will see 100 MB of heap consumed by request headers. - Taking that into account, you should review your needs and increase that value in a controlled manner. For instance, you can use twice its default value: 16384 (16KiB).
maxHttpHeaderSize="16384"
-
In tomcat<version>\conf\server.xml locate the
Connector
element and add the previous line in it:<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"
maxHttpHeaderSize="16384" />