I am hosting Chronograf behind a reverse proxy for authentication/authorization purposes, but when the authentication token cookie expires and all (the proxied) Chronografs’ XHR requests starts returning statuscode 401 (not authorized), Chronograf just keeps on re-running the requests, instead of doing a refresh of the current URL for example.
Is there a way to make Chronograf refresh the current URL in the browser window (to trigger the authentication redirect that would then happen), rather than keeping on spamming XHR requests that all will fail anyway?
One possible solution is to add a custom script in your reverse proxy configuration that listens for 401 status codes and triggers a page refresh when it encounters one. This would effectively force Chronograf to re-authenticate.
Here is a simple example of how you might implement this in Nginx:
location / {
error_page 401 = @error401;
…
}
location @error401 {
add_header ‘Content-Type’ ‘text/html’;
return 200 ‘’;
}
This script will intercept 401 errors and return a small piece of JavaScript to the client that forces a page reload. Please note that this is a workaround and may not work in all scenarios or configurations.