Welcome! Log In Create A New Profile

Advanced

Re: reverse proxy does not load webpage data

Francis Daly
February 03, 2021 01:12PM
On Tue, Feb 02, 2021 at 03:43:32AM -0500, petrg wrote:

Hi there,

> > There is no magic; it does what you configure it to do. The browser makes
> > a request to nginx; nginx handles that according to its config. Every
> > request is independent.

> My hope was that the proxy-pass directive creates not magic but some
> “context”, wraps the whole handling of the webpage into some linked
> “context”, so a bit more than just a straight location directive does. And

HTTP is stateless. Every HTTP request is independent of every other one.

As far as nginx is concerned the "context" that you want does not
exist. The "webpage" that you want does not exist. The browser makes
one request for index.html. The browser then might, or might not,
make requests for images. Those requests might, or might not, get to
this nginx.

Only the browser knows that those following requests are related to
the first one.

There have been many attempts to try to tie multiple HTTP requests
together; probably none are both reliable and appropriate for a
reverse-proxy to use.

> If every request is independent, you must know the internal structure of a
> webpage when you like to reverse-proxy it. Is that true ?

Every request is independent.

You must configure your nginx to do what you want it to do, or it probably
won't do what you want it to do.

> My feeling is that you should be able to reverse-proxy a webpage without
> knowing anything of the internal details, how data are loaded interenally.

You're welcome to try to design a thing that does what you want.

I suspect you will not succeed, in the general case.

> When I call 192.168.1.1/device/index.html I hoped that the following not
> absolute requests would be proxied to
> http://192.168.5.1/path/one.jpg,
> http://192.168.5.1/path/two.jpg, …
> as the proxy knows that one.jpg belongs to
> http://192.168.1.1/device/index.html

No, the proxy does not know that.

The proxy knows that a request came in for /device/index.html, and that
a request came in for /device/one.jpg, and that a request came in for
/path/two.jpg.

You must tell your nginx how you want those requests to be handled.

> And so it can direct the internal request for one.jpg to
> http://192.168.5.1/path/one.jpg.

location ^~ /device/ { proxy_pass http://192.168.5.1/path/; }

should do that, for every request to nginx that starts "/device/".

If you want nginx to know how to handle requests that start "/path/",
you have to tell it what to do.

> Is that a "slightly" wrong understanding of the proxy functionality ? and
> too much of magic ?

I think it's a wrong understanding of HTTP.

Once HTTP is clear, then you can see what a reverse-proxy can do.

Good luck with it!

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

reverse proxy does not load webpage data

petrg February 01, 2021 03:11AM

Re: reverse proxy does not load webpage data

Francis Daly February 01, 2021 05:54AM

Re: reverse proxy does not load webpage data

petrg February 02, 2021 02:21AM

Re: reverse proxy does not load webpage data

petrg February 02, 2021 02:24AM

Re: reverse proxy does not load webpage data

Francis Daly February 03, 2021 01:12PM

Re: reverse proxy does not load webpage data

petrg February 08, 2021 02:19AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 174
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready