Legacy Knowledge Base
Published Jul. 2, 2025

How to handle HTTP status errors with Liferay PaaS

Written By

Rodrigo Mier

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.
Note: please note that Liferay has renamed its Liferay Experience Could offerings to Liferay SaaS (formerly LXC) and Liferay PaaS (formerly LXC-SM).

Issue

  • How to configure the redirect of each HTTP status outside Liferay with Nginx.
  • Inside Liferay you are able to manage some related behaviors:
    • You can define a redirect to a page on 404 errors with the following property:
      • sites.friendly.url.page.not.found=/html/portal/404.html
    • Or show the HTTP status with the following property:
      • layout.show.http.status=true
  • With DXPCloud is posible to manage this HTTP 404 and the others HTTP status from the Webserver.

Environment

  • Liferay PaaS

Resolution

  • Nginx is able to intercept the HTTP errors and serve a static page:
    • To enable this feature just need to add the proxy_intercept_errors on; flag to the webserver config file.
    • After that, remap each error with their html page and their PATH.
  • As an example, this configuration redirects the HTTP 404 error:
    • Note for Liferay Cloud stack version 4.x: Since the root location is being customized, the file name must be liferay.conf to override the default liferay.conf
location / {
# auth_basic "Authentication Required";
# auth_basic_user_file /var/www/html/.htpasswd;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Forwarded-Port $http_x_forwarded_port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $http_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_pass http://127.0.0.1:81;
proxy_intercept_errors on;

error_page 404 /code404.html;

location = /code404.html {

root /var/www/html/;
internal;
}
}

 

Additional Information

 

Did this article resolve your issue ?

Legacy Knowledge Base