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 09:58AM
On Tue, Sep 01, 2020 at 08:40:02AM -0400, moyamos wrote:
> Francis Daly Wrote:
> > On Tue, Sep 01, 2020 at 01:12:03AM -0400, moyamos wrote:

Hi there,

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

That will end up with nginx requesting
http://externalserver.com/src/before_body.txt and
http://externalserver.com/src/after_body.txt

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

That would explain the message.

Have you the option to change externalserver.com not to issue that redirect?

(Alternatively, you could save the content into the local files and just
serve those; but I guess you want to use the external content to stay
current when it changes.)

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

That says that the nginx client and the upstream server are not able to
agree a ssl session.

Is "XXX.XXX.XXX.XXX" the same as "externalserver.com"? If
not, can you use "curl" or something similar to fetch
"https://XXX.XXX.XXX.XXX:443/src/after_body.txt" without errors?

Maybe you need some extra ssl config in nginx, such as
http://nginx.org/r/proxy_ssl_server_name and friends?

Good luck with it,

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