How do I add text to a response from a remote URL in NGINX?
    Francis Daly 
    francis at daoine.org
       
    Tue Sep  1 11:07:26 UTC 2020
    
    
  
On Tue, Sep 01, 2020 at 01:12:03AM -0400, moyamos wrote:
Hi there,
It looks like you had:
   location /src/ {
       alias /storage/path/content/;
   }
and the url /src/before_body.txt would provide the content of the local
file /storage/path/content/before_body.txt.
Now instead you want the content of the url
http://externalserver.com/before_body.txt?
In that case, just change the "alias" line to "proxy_pass
http://externalserver.com/;", and change nothing else.
> I have added a location as follows:
> 
> location ~/src/(.*) {
>         proxy_pass http://externalserver.com;
> }
This should be broadly similar, except it will fetch the url
http://externalserver.com/src/before_body.txt -- maybe that is what
you want?
> It works when the entire URL is loaded in a browser. However, in the
> "autoindex" page, "Object Moved
> This document may be found _here_" show up before and after the files list.
It works for me, providing the content of
http://externalserver.com/src/before_body.txt, before the
autoindex-generated content.
Can you show one complete config that does not do what you want?
	f
-- 
Francis Daly        francis at daoine.org
    
    
More information about the nginx
mailing list