We’re using ZTN (and it works).
I want to embed into iframe the content served on one of tunnels.
I have a dummy hello-tunnel in cloudflared.
The page opens normally and here are the response headers:
Status: 200
Response Headers (likely not important)
- alt-svc: h3=“:443”; ma=86400, h3-29=“:443”; ma=86400
- cf-cache-status: DYNAMIC
- cf-ray: …
- cf-team: …
- content-encoding: br
- content-type: text/html; charset=utf-8
- date: Sun, 18 Dec 2022 19:12:56 GMT
- nel: {“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}
- report-to: …
- server: Cloudflare
Now, when I put it into an iframe, a redirect appears:
- Status Code: 302
- Remote Address: …
- Referrer Policy: strict-origin-when-cross-origin
Response Headers (likely not important):
- access-control-allow-credentials: true
- alt-svc: h3=“:443”; ma=86400, h3-29=“:443”; ma=86400
- cache-control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
- cf-ray: …
- cf-team: …
- date: Sun, 18 Dec 2022 18:52:43 GMT
- expires: Thu, 01 Jan 1970 00:00:01 GMT
- location: …
- nel: {“success_fraction”:0,“report_to”:“cf-nel”,“max_age”:604800}
- report-to: …
- server: Cloudflare
- vary: Accept-Encoding
PS. I want to point that in the headers there is nothing related to CSP (content security policy) and no x-frame-options.
Update: After looking here: Authorization cookie · Cloudflare Zero Trust docs
I realized that this is probably because of CORS (same site iframing works, but I need an iframe on other domain).
Update 2: I found settings for CORS in application tab in ZTN, probably that’s what I was looking for.
I believe I’ve checked all options, but CF_Authorization not passed in iframe and I still get 302 to mysubdomain.cloudflareaccess.com, and that domain is not embeddable. I’ve checked in chrome and firefox, and I can access non-iframed version perfectly, but not an iframed one.
My current setup:
Access-Control-Allow-Credentials: yes
Access-Control-Max-Age (seconds): 100
Access-Control-Allow-Origin: https://website-with-iframe-in-page.com
Access-Control-Allow-Methods: allow all
Access-Control-Allow-Headers: allow all
Same-site: None
HTTP Only: true
Enable Binding Cookie: false