How do I add text to a response from a remote URL in NGINX?

Francis Daly francis at
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

In that case, just change the "alias" line to "proxy_pass;", and change nothing else.

> I have added a location as follows:
> location ~/src/(.*) {
>         proxy_pass;
> }

This should be broadly similar, except it will fetch the url -- 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, before the
autoindex-generated content.

Can you show one complete config that does not do what you want?

Francis Daly        francis at

More information about the nginx mailing list