Welcome! Log In Create A New Profile

Advanced

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

Francis Daly
September 01, 2020 07:08AM
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@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

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

moyamos August 31, 2020 03:49AM

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

Reinis Rozitis August 31, 2020 09:24AM

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

moyamos September 01, 2020 01:12AM

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

Francis Daly September 01, 2020 07:08AM

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

moyamos September 01, 2020 08:40AM

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

Reinis Rozitis September 01, 2020 09:56AM

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

Francis Daly September 01, 2020 09:58AM

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

moyamos September 02, 2020 09:11AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 192
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