httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Giovanni Gherdovich <g.gherdov...@gmail.com>
Subject [users@httpd] Reverse Proxy, mod_proxy_html. How to rewrite JS-generated relative links?
Date Sun, 17 Nov 2013 17:02:46 GMT
Hello,

I successfully configured mod_proxy_html to rewrite
relative URLs like the one in this document:

------------------------------------------
<html>
  <body>
    <a href="/x.html">link</a>
  </body>
</html>
------------------------------------------

If I serve the above document from a private network
via reverse proxying with Apache on my "frontend server"
at www.example.com and want that the "document root"
of all pages I serve from the backend is "foo",
as in www.example.com/foo/ , the link in the above doc is
correctly rewritten to

/foo/x.html

But what if the link is generated via a Javascript program
directly in the user's browser, like the following:

------------------------------------------
<html>
  <head>
    <script>
      function makeLink(){
        var node = document.getElementById("foo");
        node.href = "/x.html";
        node.innerHTML = "link";
      }
    </script>
  </head>

  <body onload="makeLink();">
    <a id="foo"></a>
  </body>

</html>
------------------------------------------

The link is not rewritten, and the GET request to

www.example.com/x.html

ends up with a sad 404.

>From the (very limited) knowledge I have about web stuff,
I don't see any way my frontend server can inject the right
link in that HTML page;

I'd like to know how do people usually handle this situation.

Regards,
Giovanni

Mime
View raw message