Jsreport render template and scripts behind enterprise Proxy
-
I am trying to run jsreport docker container on port 5488 in an environment that uses Nginx for reverse proxy. The Nginx is configured to handle forward proxies as well. When I run JsReport container and render template, I receive 502 gateway Error (Openresty). Since all the containers are running behind enterprise proxy, I suspect I am getting the error due to proxy issue. Also, I see this error (The licensing server was not reachable during instance startup. The instance now runs in the enterprise mode.) in container logs ( so I assume the jsreport container is not able to connect online to fetch license or anything). Can anyone guide me on how to use forward proxy in jsreport?
The following code runs jsreport container:
const jsreport = require('./')({ rootDirectory: __dirname })
if (process.env.JSREPORT_CLI) {
module.exports = jsreport
} else {
jsreport.init().then(() => {
}).catch((e) => {
console.log("Error:",e)
console.trace(e)
process.exit(1)
})
}
-
The licensing won't be an issue here. The server starts normally without the connection, it just writes that message to log.
Normally there is no need to configure jsreport explicitly and you only need to properly configure your proxy.
Don't you run jsreport on subpath like
http://foo.com/jsreportapp
?
-
Yes. I run it in a subpath (https://<hostname>/jsreportapp). My jsreport pdf is composed of a template + script. When I render the template and use log statements, it executes successfully. It's just the templates are not been able to render. If I create a new template with a simple text message, it works often. It's just sometimes it throws 502 bad gateway error too. More details of 502 bad gateway error:
client.js?5980ca6d76eb120c819b:6 Uncaught (in promise) Error: <html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>openresty/1.11.2.1</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
...
at b (client.js?5980ca6d76eb120c819b:6)
at client.js?5980ca6d76eb120c819b:6
at f.callback (client.js?5980ca6d76eb120c819b:55)
at f.<anonymous> (client.js?5980ca6d76eb120c819b:55)
at f.n.emit (client.js?5980ca6d76eb120c819b:9)
at XMLHttpRequest.n.onreadystatechange (client.js?5980ca6d76eb120c819b:55)
-
When running on the subpath, you need to set the following config
const jsreport = require('./')({ appPath: '/jsreportapp' })
When I render the template and use log statements, it executes successfully.
This means you see in the jsreport container output that report finished, but you see failure on the client side?
What if you just use some kind of postman/advanced rest client to invoke report rendering through API, this works?
I've never usedopenresty
so not sure if there can be a problem with it.