Is it possible to customize the Apigee Edge service/router unavailable message?

ccovney
Participant V

Hi everyone,

First things first; we are running Apigee Edge Private Cloud (OPDK) Version 4.16.09.04.

Is there any way (or best way) of customizing the default Apigee Edge service/router unavailable message? Currently, when all our APIs are down, or if the Apigee Edge Router/Message-Procs are down, the following HTML message is returned to all incoming HTTP requests:

<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>An error occurred.</h1>
<p>Sorry, the page you are looking for is currently unavailable.<br/>
Please try again later.</p>
</body>
</html>

Although this occurs rarely, it causes our client API applications to crash, as it is not a valid JSON response.

Is there any to configure or change this so that we can send back a custom JSON response instead the aforementioned stock HTML page? (I know I could likely forcibly change the underlying Nginx config, but I wanted to know if there was a better or recommended way to do this.) Thanks a lot!

Best,

Chris

Solved Solved
0 1 525
1 ACCEPTED SOLUTION

ccovney
Participant V

Thanks @Greg Galezewski for providing the answer via Apigee Support Portal!

To modify default response "Sorry, the page... " you have to modify file

/opt/apigee/edge-router/nginx/html/50x.html

manually, and replace mentioned error with anything you wish. The file does have to be called 50x.html however, but you can replace the existing HTML tags with any payload you want. I've just tested this in my own OPDK and my 50x.html looks like this:

cat 50x.html
{"test":"asdafa"}

And here is the response from Apigee Router when message-processor is down:

curl 0:9001/cavava -v
* About to connect() to 0 port 9001 (#0)
*  Trying 0.0.0.0...
* Connected to 0 (0.0.0.0) port 9001 (#0)
> GET /cavava HTTP/1.1> User-Agent: curl/7.29.0
> Host: 0:9001
> Accept: */*
> 
< HTTP/1.1 502 Bad Gateway
< Date: Mon, 27 Nov 2017 21:11:22 GMT
< Content-Type: text/html
< Content-Length: 18
< Connection: keep-alive
< ETag: "5a1c7f39-12"
< 

{"test":"asdafa"}

* Connection #0 to host 0 left intact

The only thing I noticed is that 50x.html file is not part of our configuration (CWC), which means that once you upgrade current OPDK version to latest available, the file 50x.html may be overwritten. I've already raised feature request with Engineering team so they can add it to CWC.


Regards,
Greg

View solution in original post

1 REPLY 1

ccovney
Participant V

Thanks @Greg Galezewski for providing the answer via Apigee Support Portal!

To modify default response "Sorry, the page... " you have to modify file

/opt/apigee/edge-router/nginx/html/50x.html

manually, and replace mentioned error with anything you wish. The file does have to be called 50x.html however, but you can replace the existing HTML tags with any payload you want. I've just tested this in my own OPDK and my 50x.html looks like this:

cat 50x.html
{"test":"asdafa"}

And here is the response from Apigee Router when message-processor is down:

curl 0:9001/cavava -v
* About to connect() to 0 port 9001 (#0)
*  Trying 0.0.0.0...
* Connected to 0 (0.0.0.0) port 9001 (#0)
> GET /cavava HTTP/1.1> User-Agent: curl/7.29.0
> Host: 0:9001
> Accept: */*
> 
< HTTP/1.1 502 Bad Gateway
< Date: Mon, 27 Nov 2017 21:11:22 GMT
< Content-Type: text/html
< Content-Length: 18
< Connection: keep-alive
< ETag: "5a1c7f39-12"
< 

{"test":"asdafa"}

* Connection #0 to host 0 left intact

The only thing I noticed is that 50x.html file is not part of our configuration (CWC), which means that once you upgrade current OPDK version to latest available, the file 50x.html may be overwritten. I've already raised feature request with Engineering team so they can add it to CWC.


Regards,
Greg