I think the answer to this question is "no", but I thought I'd ask here to be sure. I am writing a web application and I need to access JavaScript code from a subdomain on another domain. This isn't allowed by web browsers because it's considered cross-site scripting.

This whole problem would go away if both machines could somehow be mapped to the same domain and just route the individual page requests to the correct place. So http://example.com/App1.aspx and http://example.com/App2.aspx would actually sit on separate machines.

Is this technically possible?

Thanks for any help.

  • What do you mean by "access Javascript code"? There are some things you can enable across domains which might make the proxy problem go away. Like CORS headers for cross domain Ajax calls.
    – Matt
    Mar 5, 2013 at 19:39
  • Perhaps not stated the most elegant way, but I need to access DOM elements of a page from a sub-domain hosted in an iframe via JavaScript from the top-level domain outside the iframe. From what I understand, CORS requires both domains "agree" to it. I can't modify the page source coming from the sub-domain.
    – MgSam
    Mar 5, 2013 at 19:44
  • Ah.. well CORS requires some headers to be set on the response from the domain you are sending the request to, your subdomain, to allow the requesting domain access. If you don't control the sub domain server then you'll probably need the proxy for your XSS. If you could add the headers, you can dump the IFrame and load the data into a div with Ajax and modify as needed.
    – Matt
    Mar 5, 2013 at 19:58

2 Answers 2


Yes, it's possible to proxy requests to separate nameservers based on a variety of rules.

IIS appears to have such a capability, called Application Request Routing.


What you're looking for is known as a reverse proxy.

Nginx is a popular open source reverse proxy.

In this scenario you would point example.com's DNS to the proxy which would choose which web server to use based on the content of the request.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .