URL Redirect Problems

Francis Daly francis at daoine.org
Fri Nov 12 21:54:54 MSK 2010


On Fri, Nov 12, 2010 at 01:06:51PM -0500, fwKilo wrote:

Hi there,

> Thank you for the advice, Francis. I do own both websites and they exist
> on the same server. I'll try to clarify in what I'm trying to achieve. I
> want the URL to stay the same in the browser (which would be
> "http://proxy.mysite.com/tango") but display all of the content display
> from "http://bravo.mysite.com" and also be able to view other content on
> that page.

Right.

So the browser asks for http://proxy.mysite.com/tango/one.html,
and it gets the content from http://bravo.mysite.com/one.html,
which will link to and include other urls -- which will be of
the form "http://bravo.mysite.com/one.png" (in which case the
browser will go directly to bravo, bypassing proxy); or of the form
"/one.png" (in which case the browser will complete that url to
"http://proxy.mysite.com/one.png", which will probably fail to be served
correctly); or of the form "one.png" or "./one.png" or something else
that does not start with "/" (in which case the browser will complete
the url to "http://proxy.mysite.com/tango/one.png", and the request
should succeed).

So you *must* ensure that every link that comes back from
every page within "http://bravo.mysite.com" does not start with
"http://bravo.mysite.com" and does not start with "/". Or, they must be
adjusted before they go to the browser.

> There are frankly, way too many links for me to change in
> order to do this, so I thought I'd do it with nginx. So when a user
> visits "http://proxy.mysite.com/tango", they stay on that URL, but
> they're actually on "http://bravo.mysite.com/" and could surf that site
> normally.

Yes, they can. But only if anything that the browser might
interpret as a url to be completed, is correct according to the
"http://proxy.mysite.com/tango" url space by the time it reaches the
browser.

This isn't an nginx thing, it's a (html) url-resolving thing.

You can filter the content in nginx on every request (although it's
unlikely to be easy to do right), or you can set it right once on the
back-end.

(I assume it isn't already all right on the back-end, because you report
none of the images working. The html returned, and the web servers'
logs should show you exactly why they aren't working.)


Since the two sites are on the same server, you might be able to configure
"proxy" to serve the "bravo" files directly. But that won't help the
"partial urls starting with /" thing.

Whichever you choose, good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list