reverse proxy does not load webpage data

petrg nginx-forum at forum.nginx.org
Tue Feb 2 08:43:27 UTC 2021


Hey Francis, 

thanks a lot for your extensive answer.
Now I understand much better. 
But let me discuss one misty point.

> 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.
> 
> > How should nginx(PC-proxy) know, where to find the image-file
> > /images/logo.jpg that is asked for by the webpage ?
> 
> You need to configure your nginx to do what you want it to do.

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
so all the following requests from that webpage live in that “context”.
So when you define a proxy-pass to 192.168.5.1/path all the following
requests from that webpage starting with 192.168.5.1/path/index.html should
be directed to at least 192.168.5.1.

If every request is independent, you must know the internal structure of a
webpage when you like to reverse-proxy it. Is that true ?
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.
So my hope was that the proxy directive wraps the webpage and all the
internal requests and knows where to direct the related requests to.

> When the browser talks to PC-proxy and asks for
> http://192.168.1.1/device/index.html it gets the same html back,
> and it makes five new requests for 
> http://192.168.1.1/device/one.jpg,
> http://192.168.1.1/path/two.jpg, 
> ...

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 what is proxied to
http://192.168.5.1/path/. 
And so it can direct the internal request for one.jpg to
http://192.168.5.1/path/one.jpg. 

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

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,290609,290623#msg-290623



More information about the nginx mailing list