Jump to content
Welcome to our new Citrix community!

Use own "Error-Page" (404 / 5xx) instead of the backend default Error-Page


nlffel439

Recommended Posts

Hello @ all ?,

I would like to display a custom error page, instead of the Backend 404 default page.

 

Example:

User call "www.example.com/pagedoesnotexist" and then gets the "customfail.html" displayed.

 

I have started to build a responder action with the parameter  "Respond with HTML Page" I have already built the custom page ("customfail").

 

add responder action res_act_respond_with_404 respondwithhtmlpage customfail -responseStatusCode 404

I have not entered anything under Headers.

image.thumb.png.ea21674c24a0f06ab8a85a2922fff7e5.png

 

However, a responder policy with "HTTP.RES.STATUS("404") does not work. 

Can I implement this idea with a responder policy at all or do I have to implement this with a rewrite policy ?

However, if I use a rewrite policy for implementation, I can not include a "customfail.html" but must use the HTML code as an expression.
 

 

Many greetings 

Link to comment
Share on other sites

The custom respondwith action, means you have to WRITE the entirety of a valid HTTP response: response code/message, headers, body content.

HTTP/1.1 404 Page Not Found\

Connection:Close

 

Every header terminates with a \r\n the header section terminates with a double \r\n\r\n.  The body content terminates with a \r\n\r\n 

 

You would have to write out:

"HTTP/1.1 404 Page Not Found \r\n" + "Connection:Close\r\n\r\n"

 

At a bare minimum.

 

 

 

  • Like 1
Link to comment
Share on other sites

First of all, thanks for the tip Rhonda ?

I have now solved my issue by building a combination of Rewrite Policy and Responder Policy.

 

This was necessary because the Rewrite Policy does not offer the possibility to upload a "Customhtml-File" to the ADC to use it. 

And calling an external location that leads to the page was not an option for me.

 

The rewrite Policy triggers with a status code 404 or 500-510 

The rewrite Action redirects to the location "/error".
 

The responder policy which is also integrated in the vServer triggers at "/error" and responds with the "customfail.html". 

 

Here as an Config example with status 404:
 

add rewrite action replace_backend_404-page_rew_ACT replace_http_res q{"\"HTTP/1.1 302 Temporary Redirect\nLocation: /error \n\n\""}	
add rewrite policy replace_backend_404-page_rew_POL "HTTP.RES.STATUS.EQ(404)" replace_backend_ERROR-page_rew_ACT	

add responder action res_act_respond_with_error respondwithhtmlpage customfail -responseStatusCode 404	
add responder policy redirect-pol_respons_with_ERROR "HTTP.REQ.URL.CONTAINS(\"/error\")" res_act_respond_with_error

bind lb vserver vServer_NAME -policyName replace_backend_404-page_rew_POL -priority 100 -gotoPriorityExpression END -type RESPONSE
bind lb vserver vServer_NAME -policyName redirect-pol_respons_with_ERROR -priority 100 -gotoPriorityExpression END -type REQUEST	

If the configuration should trigger at 5xx, only one more rewrite policy has to be built

 

add rewrite policy replace_backend_5xx-page_rew_POL "HTTP.RES.STATUS.BETWEEN(500,510)" replace_backend_ERROR-page_rew_ACT	

 

If a user now enters a wrong URL path and triggers a 404 status or a 5xx error is response by the backend, the message is now replaced by the customfail.html.

 

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...