Welcome! Log In Create A New Profile

Advanced

Re: Proxy pass set body on if

Francis Daly
February 21, 2021 10:56AM
On Tue, Feb 16, 2021 at 10:00:47AM -0500, sanflores wrote:

Hi there,

> I have an Angular app and need to use puppeteer for SSR. In order to make it
> work I need to send the request with the body but I can't figure how to make
> these things work together.

Can you see, which part is failing? Is it "you set the body, but it is
not what you expect"; or something else?

If you "tcpdump" the port-3000 traffic, do you see anything interesting?

> if ($limit_bots = 1){
> proxy_pass http://localhost:3000/puppeteer/download/html/;

I get:

nginx: [emerg] "proxy_pass" cannot have URI part in location given by
regular expression, or inside named location, or inside "if" statement,
or inside "limit_except" block

(And more failures, after changing that. Generally: there are limited
things that you can do inside an "if" block.)

If you remove that "if", do things work differently for you?

> proxy_method GET;
> proxy_set_header content-type "application/json";
> proxy_pass_request_body off;
> proxy_set_body "{\"url\":\"https://$request\"}";
> }

http://nginx.org/r/$request

That is probably not the variable that you want to use.

Maybe some combination of $server_name or $host, and $request_uri,
is more useful?

> The idea would be to redirect bots to the static html that will be provided
> by puppeteer runing in another server, and adding proxy_server inside an if
> is deprecated. I should be using a rewrite statement... but I can't set the
> body.

Reverse the test?

if ($is_a_bot) {
return / rewrite / whatever
}
proxy_pass ...

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

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