Jump to content
Welcome to our new Citrix community!

Responder with complex HTML page and custom return code


Sasha Dundovic

Recommended Posts

On NetScaler 10.1, I have a responder action configured with 'respondwithhtmlpage' and it points to specific web page content. When triggered, this responder returns HTML code 200 by default. I'd like to have HTML error code 503 returned instead. I was able to find some documentation in the support database (CTX117337) but this describes a situation with a very basic, one-line web page. None of the support docs explain how to use 'respondwithhtmlpage' with some custom return code in conjunction with complex web page.
 
Any advice is appreciated.
 
.

 

Link to comment
Share on other sites

If you want the users to see  the error as '503 Service Unavailable' with the html page , I suggest you to edit the .html page and insert a line with this error code . This will let you to show User with your custom page and the desired error code .

No user will validate whether the actual status code is '200 ok' or '503 service unavailable' error since these error code will be in the HTTP header 'status code' and won't show up on the page which client will be viewing.

 

If you want the Netscaler to send 503 error  you can kill the httpd daemon, then you wont be able to display the .html page with it , and this will cause other services(GUI,VPN-GUI) of netscaler to fail also (complete disaster) :) .

Link to comment
Share on other sites

Actually, I need to have return code in the header, that's the whole point. This 503 has to be returned during maintenance period. If you're familiar with SEO requirements, you'll know exactly what's my point and why this is required. I'm surprised that this option actually exists (as described in CTX117337), but there's no way to have it with either more complex web page or 'respondwithhtmlpage' option. There must be some way....

Link to comment
Share on other sites

If you use the "Respond With" option, you build the whole page (starting with the "HTTP/1.1 503 Service Unavailable\r\n\r\n" line).

 

This allows you to build simple responses, which are 100% in your control... I guess that, if you can host content elsewhere, then you could build a simple "top" page with links to the external content

 

Another way to do what you want would be to.... create a new LBVS, that points to a spare server hosting some "sorry" pages, then make that the "backup vserver" for your main server. When the main server goes offline (or you MAKE it offline) then traffic gets internally diverted to that "sorry" server. Clearly, you can make that server deliver whatever content you like.

 

Alternatively, put in a CSWVS in front of the LB, pass "default" traffic to the existing LB, then use a policy to detect "sorry" pages ("url starts with /sorry/...." sort of thing) to send to the LB / sorry server. Then you do what I said above, respond with the 503, with extra content pulled from "http://sameurl.com/sorry/......"

 

Any of those work for you?

Link to comment
Share on other sites

Actually, I already tried that with following responder action that has a simple HTML and GIF embedded:

 

add responder action TEST respondwith "\"HTTP/1.0 503 Service Unavailable\" +\"\\r\\n\\r\\n\" + \"<!DOCTYPE html>\n   <html>\n    <head>\n        <title>TEST</title>\n    </head>\n     <body>\n     <img style=\'display:block; vertical-align: top; margin-left: auto; margin-right: auto; width:80px;height:80px;\' id=\'base64image\'                 \n   \"+\"    src=\'data:image/gif;base64,E45A..blah-blah...image-content..AAB7=\n\n\n\' />\n   </body></html>\" + \"\\r\\n\""

 

Even that would be a good option as I could create a GIF screenshot of the productive maintenance page, but the problem with this approach is only 8191 bytes length limit and that notorious requirement to insert "+" every 255 bytes. Not really a 'user friendly' approach :). (It would be nice to see that addressed/enhanced in some update....)

 

Having external, dedicated web server to serve that maintenance page is definitely a workaround (functional, but not elegant at all, though). This should be handled by the appliance itself with absolutely no hassle. FYI, I have BigIPs in the environment, too. They don't require any external server to perform this task, no matter of the HTML complexity.

Link to comment
Share on other sites

  • 1 year later...

If I take screen shot of my maintenance page and convert it into base 64, the size of the code breaches the limit of 8191 byte. Is there any other way to rewrite the status code through response rewrite policy?? If i try to create responder action respond with simple html code it says syntax error- The code of html page is very simple that is given below-

 

"\"HTTP/1.1 403 Forbidden\" +\"\\r\\n\\r\\n\" + \"<!DOCTYPE html>\n   <html>\n    <head>\n        <title>CLIENT AUTH REQUIRED</title>\n    </head>\n  
<body style="background-color:#3366cc">
<h1 style="color:red;" align="center">IMPORTANT MESSAGE</h1>
<p style="color:white;" align="center">This Site Requires Client Certificate</p>
</body> </html>>\" + \"\\r\\n\""
Link to comment
Share on other sites

  • 3 years later...

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...