Legacy Knowledge Base
Published Jun. 30, 2025

Unable to Save Forms After Enabling ModSecurity

Written By

Tímea Bihari

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • After enabling ModSecurity with the default settings, forms with more than three fields cannot be saved.
  • The following error message is displayed in the logs:
    ModSecurity: Access denied with code 400 (phase 2). Matched "Operator `Eq' with parameter `0' against variable `REQBODY_ERROR' (Value: `1' ) [file "/etc/nginx/modsec/modsecurity.conf"] [msg "Failed to parse request body."] [data "Request body excluding files is bigger than the maximum expected."]
    

 

Environment

  • Liferay PaaS

 

Resolution

Increase the request body size limits in the ModSecurity configuration file:

  1. In the webserver service settings, ensure the LCP_WEBSERVER_MODSECURITY environment variable is set to On.
  2. Access the webserver service's shell and navigate to the /etc/nginx/modsec directory.
  3. Open the modsecurity.conf file.
  4. Find the following lines, where the size limit should be set to ~13MB (you will find the description above them explaining that the first line is the file size limit, the second is the non-file related request body data size, which should be as low as possible to reduce the chances of certain types of attacks taking place against your web application firewall):
    SecRequestBodyLimit 13107200
    SecRequestBodyNoFilesLimit 131072
  5. Increase the size for both properties to 30107200 and 301072
  6. To ensure ModSecurity respects the environment variable setting, change the SecRuleEngine directive to use the environment variable.
    SecRuleEngine ${LCP_WEBSERVER_MODSECURITY}
    
  7. Deploy the changes to apply the updated ModSecurity configuration.

 

Additional Information

  • The default size limits are industry standards for Web Application Firewalls (WAFs) to prevent certain types of attacks. Increasing these limits may increase your vulnerability to certain attacks.
  • Please note that the solution requires customizing the application. This means that your Developer Team should perform it at your discretion. It should also be tested on a lower environment and make a backup of the database before modifying the settings. If you require assistance and consultation, we recommend contacting our GS (Global Services).
Did this article resolve your issue ?

Legacy Knowledge Base