Welcome! Log In Create A New Profile

Advanced

Re: Proxy pass set body on if

Francis Daly
February 22, 2021 04:12PM
On Mon, Feb 22, 2021 at 02:15:42PM -0500, sanflores wrote:

Hi there,

I suspect that if I were doing this, I would probably pick one url that
is not otherwise used on my server (in this example, "/puppet/"), and
use that as a "stepping stone".

Then, if this request should be handled specially, rewrite to that url,
ad do the proxy_pass and friends in there.

There may be better ways, but this appears to give the desired response.

> So the question would be, what configuration would be needed in order to
> redirect the crawlers (based on $http_user_agent) to puppeteer modifying the
> body?

> server {

Somewhere at "server" level, outside of other location{} blocks, add:

==
if ($limit_bots = 1) { rewrite ^ /puppet/? break; }

location = /puppet/ {
internal;
proxy_pass http://localhost:3000/puppeteer/download/html/;
proxy_method GET;
proxy_set_header content-type "application/json";
proxy_pass_request_body off;
proxy_set_body "{\"url\":\"$scheme://$host$request_uri\"}";
}
==

Note that the variables in "proxy_set_body" do matter -- they relate to
the request received by this nginx.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Proxy pass set body on if

sanflores February 16, 2021 10:00AM

Re: Proxy pass set body on if

Francis Daly February 21, 2021 10:56AM

Re: Proxy pass set body on if

sanflores February 22, 2021 07:52AM

Re: Proxy pass set body on if

Francis Daly February 22, 2021 01:14PM

Re: Proxy pass set body on if

sanflores February 22, 2021 02:15PM

Re: Proxy pass set body on if

Francis Daly February 22, 2021 04:12PM

Re: Proxy pass set body on if

sanflores February 23, 2021 04:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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