Hello, I’m new here and have an odd scenario.
I have OpenSearch as an AWS service, and I would like to make a dashboard available outside of OpenSearch. OpenSearch allows you to embed a dashboard in iframes and even provides the HTML to do so.
I created a simple Alpine-based nginx pod in my Kubernetes and set up the proxy pass to allow access. The proxy handles the same-origin cookies and script blocks, among other things.
Currently, because the proxy is inside my Kubernetes, I’m passing the login credentials in the header from the proxy to the AWS service.
This is all essentially working; I log in to the custom front end, click the dashboard, and the iframe loads the dashboard.
The issue: Of course, anyone can take the iframe URL and view it directly.
I’m looking for advice on the best solution.
- No direct access to OpenSearch
- No direct access to the Dashboard via proxy
- Must log in through our interface.
- Ideally, not have the user log in to the dashboard separately in an iframe.
Both the web front end and the proxy are in the same domain.
Main Website Ingress DNS
web.mydomain.com
Proxy Service Ingress DNS
dashboard.mydomain.com
Thoughts:
Is there a way in Nginx to restrict access only to an iframe?
if !iframe return 404
if iframe and parent domain is web.mydomain.com return page
I know you can restrict an iframe to the same domain or a specific domain.
Content-Security-Policy: frame-ancestors 'self' https://web.mydomain.com;
This works, but does not prevent direct access.
Thoughts on using JWT
I have never tried or tested it, but I understand that you can configure Nginx with JWT.
If anyone has done this, what are your thoughts on this idea?
Has part of the backend service, generate a signed 20-minute JWT token and passes it to the proxy in the iframe parameters.
Nginx validates the JWT and passes the dashboard. The user could still break out of the iframe, but they could only do that for the 20 minutes the JWT is valid.
I am open to any suggestions or advice. I have access to all the components; the only restriction is that OpenSearch runs as an AWS service, not in a pod.
Thanks in advance.
Harry