Welcome! Log In Create A New Profile

Advanced

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

September 01, 2020 08:40AM
Francis Daly Wrote:
-------------------------------------------------------
> On Tue, Sep 01, 2020 at 01:12:03AM -0400, moyamos wrote:
>
> Hi there,

Thanks Francis for your reply. :-)

> 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?

Yes, that's right.

[...]

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

server {
listen 80;

root /storage/path;
index index.html;

server_name test.domain.com;

location / {
try_files $uri $uri/ =404;
add_before_body /src/before_body.txt;
add_after_body /src/after_body.txt;
autoindex on;
}

location /src/ {
# alias /storage/path/content/;
proxy_pass http://externalserver.com;
}
}

The result is the same as my previous location. "Object Moved This document may be found _here_" is showing up before and after the files list. When I am clicking on the "_here_" link, the content is loaded correctly. But, on "https". There is a redirect from "http" to "https" on externalserver.com.

As soon as I am changing to

location /src/ {
proxy_pass https://externalserver.com;
}

following errors are logged:

2020/09/01 16:48:41 [error] 8445#8445: *33789440 peer closed connection in SSL handshake (104: Connection reset by peer) while SSL handshaking to upstream, client: YY.YYY.YYY.YY, server: test.domain.com, request: "GET / HTTP/1.1", subrequest: "/src/after_body.txt", upstream: "https://XXX.XXX.XXX.XXX:443/src/after_body.txt", host: "test.domain.com"
2020/09/01 16:48:41 [error] 8445#8445: *33789440 peer closed connection in SSL handshake (104: Connection reset by peer) while sending to client, client: YY.YYY.YYY.YY, server: test.domain.com, request: "GET / HTTP/1.1", subrequest: "/src/after_body.txt", upstream: "https://XXX.XXX.XXX.XXX:443/src/after_body.txt", host: "test.domain.com"

>
> 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: 224
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