openlitespeed icon indicating copy to clipboard operation
openlitespeed copied to clipboard

Server level custom error pages not working.

Open amirhmoradi opened this issue 5 months ago • 3 comments

Hi :) In my setup, I want to show a custom error page when mod security (owasp) throws an error like 403. I use openlitespeed.

How can I make this happen? I tried putting custome error pages on the server config level (httpd_conf.conf) with no success like this:

context /error.html {
    location  /var/www/vhosts/localhost/html/error.html
    allowBrowse           1
    indexFiles error.html
}
include /usr/local/lsws/conf/custom_error_pages.conf

I tried also putting the custom error pages on vhost level, no success...

I found that the 403 pages come out of httpsstatuscode.cpp https://github.com/litespeedtech/openlitespeed/blob/252f18c1c56fcd6ccbea17ddd9d27696470eed31/src/http/httpstatuscode.cpp#L207.

Please advise :)

amirhmoradi avatar Jun 26 '25 13:06 amirhmoradi

You can customize error page under each individual virtual host, under "General" tab -> "Customized Error Pages" table.

litespeedtech avatar Jun 29 '25 17:06 litespeedtech

thanks for the response, but I see you did not understand the situation. I am not looking to customize the pages for a vhost, but for the moment when the owasp security module returns a 403 error. In this case the error page is rendered from the openlitespeed server code, not from any vhost. Please advise.

Regards.

amirhmoradi avatar Jun 29 '25 19:06 amirhmoradi

At this moment it’s not possible. The response is hardcoded inside httpstatuscode.cpp (https://github.com/litespeedtech/openlitespeed/blob/master/src/http/httpstatuscode.cpp).

It would be interesting to refactor all that code to provide not only fully customizable general error pages but also better condition checking.

Because I also experience that when using a proxy inside a VHost, sometimes it returns the hardcoded 503 instead of the customized error page belonging to the VHost.

TTSHAR avatar Aug 30 '25 10:08 TTSHAR