PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, April 15, 2022

[FIXED] How do I make a page accepts Iframe requests from my website only while using cloudflare?

 April 15, 2022     apache, cloudflare, iframe, ip     No comments   

Issue

I have a website, decided to serve some gaming pages.

So I made a subdomain with it's own server and IP.

I'm using cloudflare on my games subdomain and my main domain and apache server.

I want to only allow my website to render or be able to use "iframe" tag to render the pages from the subdomain.

Restrict any other IP to render these pages.

So I tried many solutions like .httaccess file or making rules. Is this doable?

And I need to know even it's not on cloudflare or proxied.

If I only allow website's IP address to access the subdomain, when the user request this page, is the request come from the user's IP or the website's IP?

Wouldn't that make a conflict?

Thanks


Solution

I think what you need is to set up appropriate X-Frame-Options response headers, as well as Content Security Policies so that you can instruct the browser on what resources can be loaded from the main HTML document containing your iframe.

Then you'll also want, in your iframe content page, to check whether it is being loaded within your main page or not. If not, redirect the user to the main page.

You won't be able to "restrict by visitor IP" since you don't know beforehand which IPs end users will have (assuming you are dealing with a public website)



Answered By - Paolo Tagliaferri
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing