Welcome! Log In Create A New Profile

Advanced

Re: Nginx seems to ignore proxy_set_header Host directive

Francis Daly
February 11, 2013 04:44PM
On Mon, Feb 11, 2013 at 04:13:28PM -0500, jeangouytch wrote:

Hi there,

> > Can you give an example of what you do, what you see, and what you
> > expect to see? "curl -i" is usually a good way of showing the headers
> > and content returned.
> >
> Ok, I think i'm not using the right words, maybe "rewriting" is not the
> exact term. My problem is :
> relative path for images are normal in the html files, looking like
> "/media/myimage.jpg"
> I understand that the proxy_set_header directive would make the relative
> path to be treated as serverIP/pyload/media/myimage.jpg,

No, proxy_set_header doesn't do that. http://nginx.org/r/proxy_set_header
for details of what it does do.

I don't know of any reliable way to get nginx to correctly change the
content of html files, and anything else that the browser might interpret
as containing local urls, so that everything works as you wish.

The easiest two ways of proxying multiple servers are: convince the
"pyload" server that all of its content is *actually* below /pyload,
so that it generates "correct" urls itself (and do something similar for
each other internal server); or use different hostnames for each internal
server, and have different server{} blocks in nginx.conf proxy_pass to
different internal servers.

The third way is to ensure that all of the content on all of the internal
servers never refers to any local url that starts with "/" -- so instead
of "/media/myimage.jpg" it would be "../../media/myimage.jpg", with the
correct number of "../" components each time.

The first two ways are "matching subdirectories on the proxy and proxied
servers"; the third is "great care on the proxied server".

If you have a restricted, controlled set of file contents on each server,
then you might be able to use one of the substitution filter modules to
make enough changes that it works well enough for you.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx seems to ignore proxy_set_header Host directive

jeangouytch February 11, 2013 10:44AM

Re: Nginx seems to ignore proxy_set_header Host directive

Francis Daly February 11, 2013 02:10PM

Re: Nginx seems to ignore proxy_set_header Host directive

jeangouytch February 11, 2013 04:13PM

Re: Nginx seems to ignore proxy_set_header Host directive

Francis Daly February 11, 2013 04:44PM

Re: Nginx seems to ignore proxy_set_header Host directive

jeangouytch February 12, 2013 02:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 66
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready