So the scenario we have in mind is as follows.
We have an IFRAME. Said IFRAME wants to point to a resource on https://trees.com
. It might be, for example, https://trees.com/ficus/macrophylla
. However, despite all our requests to trees.com
, they refuse to allow us to link directly to their site, blocking the cross-origin request.
So we decide we want to set up a reverse-proxy. We've heard about nginx and apache but we've got a corporate commitment to Microsoft's technology, for better or worse, so decide in favour of IIS.
Using one of our Azure servers, we create a website, let's call it https://figs.wild.com.au
. We configure the IFRAMEs so that a request to https://trees.com/ficus/macrophylla
actually goes to https://figs.wild.com.au/trees/ficus/macrophylla
.
At this point we go slightly insane.
Is it actually possible for the request https://figs.wild.com.au/trees/ficus/macrophylla
to be converted, on the figs.wild.com.au
server, to a request for https://trees.com/ficus/macrophylla
and for the response to that to be fed back to the originator of the IFRAME request?
We've done a lot of searching and we keep finding things that almost work. What actually does work? Is IIS's Url Rewrite the thing to use, and if so, what should the rule/s look like? Or should we be using some C#-y thing instead?
If I go to http://www.trees.com/ficus/macrophylla using the browser, then will get
If I go to http://www.trees.com/ will also get the following
Using SSL Request to trees.com
Clicking "Click here to ignore the mismatch...", will then get
In the configuration,
we can see TLS 1.0, 1.1, 1.2 and 1.3 are supported. Yet, green color for TLS 1.2 and 1.3.
We can configure PowerShell to use TLS 1.3
And confirm it will be using it
In PowerShell (as Administrator), if one uses Invoke-WebRequest
then will get
and if one uses
then will get
So far so good. But if we want to test it for CORS from the https://figs.wild.com.au,
we get
Notice that Access-Control-Allow-Origin has the value asterisk (*) which means that any domain is allowed. Then, if we use the following command
we will get the following result
In other words, it's allowing cross-origin request and not blocking like you're mentioning in the question. Could be that you're giving fictitious URLs too just for the sake of the explanation.
In regards to the question and considering the comments, redirection to an external URL is possible in IIS as shown here.
Also, a simple redirect is possible using NGIX and is addressed, for instances, in this answer.
and in this answer
Yet, what you want isn't to see the content of that page but to save that data anywhere and then redirect again. Where will that data be coming from then to feed the IFRAME?
Instead of doing this
redirect > save data > redirect
, I would suggest to do that separately. More specifically, you'd get the data from https://trees.com/ficus/macrophylla and save it in the location of https://figs.wild.com.au/trees/ficus/macrophylla and use what you want from that file for the IFRAMEs.To get the content of the file in the location https://trees.com (without JS and CSS coming from other files) and save it in an html file, you'd do something like
This will save the content in an HTML file named test present in the same location of this script.
(If CSS and JS is also required, do check this SO question).
If you don't want to go through that hustle, there's tools like HTTrack that allow to download complete websites. This way you wouldn't need to know the mapsite to then iterate over the possible variations.
I can see the convenience of what you want. Will investigate further and let you know if find that super-automated way to do this but would help to know "Where will that data be coming from then to feed the IFRAME?".